Project

Profile

Help

s9api - how to create xdmnode

Added by Anonymous almost 15 years ago

Legacy ID: #7526275 Legacy Poster: Stephen Nell (srn253e)

I know how to construct a document in memory with saxon s9api, as long as I can read in the xml document from a file or other source.. but how can I dynamically create a document that does not already exist.. ( i.e. create document node, add child nodes, etc.. ) is documentbuilder.wrap(org.w3c.dom.Element) the quickest way?


Replies (4)

Please register to reply

RE: s9api - how to create xdmnode - Added by Anonymous almost 15 years ago

Legacy ID: #7526429 Legacy Poster: David Lee (daldei)

Not sure what you mean by "quickest" but that does work. DOM is not the best architecture for creating XML documents but it does work and is prevalent. You can also use XQuery to create nodes that S9 API can natively use. You can also use SAX API's but thats a bit tricky because its a "pull" architecture. Or you can use text xml in a string, then parse that string as an XML document, for example you can use SAX or StAX or any other serializer to construct XML Text then parse it as a document.

RE: s9api - how to create xdmnode - Added by Anonymous almost 15 years ago

Legacy ID: #7526447 Legacy Poster: Michael Kay (mhkay)

Of the various implementations of NodeInfo, the TinyTree is not updateable by design - its efficiency comes from the fact that it can only be built sequentially by firing SAX-like events at the builder. Of course, you can do that from code if you want, provided you can send the events in the right sequence. The LinkedTree is updateable in situ since Saxon 9.1, but the update interfaces are designed specifically to support XQuery Update and not really as a user-friendly API. I would recommend creating and wrapping a XOM - it's a much more XPath-friendly model than DOM, and much more efficient; read access via Saxon is not much slower than the TinyTree.

RE: s9api - how to create xdmnode - Added by Anonymous almost 15 years ago

Legacy ID: #7526450 Legacy Poster: Michael Kay (mhkay)

The other thing I would mention is that if you want to create a document programmatically, it's much easier to write your code in XSLT or XQuery than in Java!

RE: s9api - how to create xdmnode - Added by Anonymous almost 15 years ago

Legacy ID: #7526488 Legacy Poster: Stephen Nell (srn253e)

thank you both for the prompt responses... very helpful

    (1-4/4)

    Please register to reply