Re: What's the s9apiest way to say text { $i } ?
Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> Wed, 24 Feb 2021 08:04:15 +0000
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <[email protected]> |
s9api isn't really designed for this job: it's designed primarily for firing off queries and transformations, and processing their results. In 10.0 we introduced two new APIs for tree construction, the Push API and the Sapling API, but they're both designed for programmatic construction of complete XML documents, and don't have any mechanism for creating parentless text nodes. You would have to dive into lower-level APIs. Create an instance of net.sf.saxon.tree.util.Orphan, set its properties, and then cconstruct an XdmNode as `new XdmNode(orphan)`. Michael Kay Saxonica > On 21 Feb 2021, at 23:57, Chapman Flack <chap-JULfBfA8satPFr4CO1/[email protected]> wrote: > > Hi, I'm trying to express this bit of XQuery directly in s9api: > > > typeswitch ( $i ) > case $a as attribute(*) return text { $a } > default return $i > > > > I think it would be something like this (i an XdmItem), > but what's the s9apiest way to write the ??? below? > > > > if ( i instanceof XdmNode n ) { > if ( ATTRIBUTE != n.getNodeKind() ) > return n; > return ??? /* make a text node from n.getTypedValue() */ > } > else > return i; > > > Thanks! > > Regards, > -Chap > > > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [email protected] > https://lists.sourceforge.net/lists/listinfo/saxon-help _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [email protected] https://lists.sourceforge.net/lists/listinfo/saxon-help