|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
How to manually create XdmNode?Hi,
I have a new problem... I want to create some XdmNode myself in Java. So I look the API documentation. There is a constructor which take a parameter NodeInfo, and then I'm searching which way is the most suitable to create this NodeInfo. To explain my problem further : I'm working on a search engine for XML document based on the Java language. So I build an index which is a set of reverse lists like : word1 -> elementX, elementY word2 -> elementZ ... All my program use XdmNode to handle XML element (because of the equal() method). To render the result of a search I develop a little XSLT and now I want to run this XSLT using the s9api with XdmNode as input/output... I just want to create a result XML tree like this : <results words="..." time="..."> <result> ... </result> <result> ... </result> <result>... </result> </results> And so I need to create XdmNode for <results /> and <result />. Regards, Bruno. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: How to manually create XdmNode?Yes, I've realised the lack of this constructor is a bit of a pain, so I'm going to provide it in the next release. Its absence was motivated by a desire to keep the s9api interface as self-contained as possible, discouraging people from mixing APIs at different levels. >From your description it's not clear to me why you can't create your XdmNode by defining an XdmDestination as the output of the transformation. But if you do need to create an XdmNode from an existing NodeInfo, you can do it using the DocumentBuilder.wrap() method. Regards, Michael Kay http://www.saxonica.com/ http://twitter.com/michaelhkay > -----Original Message----- > From: bruno le hyaric [mailto:bruno.lehyaric@...] > Sent: 01 November 2009 19:31 > To: saxon-help@... > Subject: [saxon] How to manually create XdmNode? > > Hi, > > I have a new problem... > > I want to create some XdmNode myself in Java. So I look the > API documentation. > There is a constructor which take a parameter NodeInfo, and > then I'm searching which way is the most suitable to create > this NodeInfo. > > To explain my problem further : > > I'm working on a search engine for XML document based on the > Java language. So I build an index which is a set of reverse > lists like : > > word1 -> elementX, elementY > word2 -> elementZ > ... > > All my program use XdmNode to handle XML element (because of the > equal() method). > > To render the result of a search I develop a little XSLT and > now I want to run this XSLT using the s9api with XdmNode as > input/output... > > I just want to create a result XML tree like this : > > <results words="..." time="..."> > <result> ... > </result> > <result> ... > </result> > <result>... > </result> > </results> > > And so I need to create XdmNode for <results /> and <result />. > > > Regards, > > Bruno. > > -------------------------------------------------------------- > ---------------- > Come build with us! The BlackBerry(R) Developer Conference in > SF, CA is the only developer event you need to attend this > year. Jumpstart your developing skills, take BlackBerry > mobile applications to market and stay ahead of the curve. > Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > saxon-help mailing list archived at > http://saxon.markmail.org/ saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: How to manually create XdmNode?I found a first-step solution. I simply use the Java DOM
implementation to create the document tree... but I have to insert XdmNode in it and these XdmNodes come from other XML documents... So I try to use the cloneNode() method like this : NodeOverNodeInfo.wrap(xdmNode.getUnderlyingNode()).cloneNode(true); and I get the exception : Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: The Saxon DOM cannot be updated at net.sf.saxon.dom.NodeOverNodeInfo.disallowUpdate(NodeOverNodeInfo.java:687) at net.sf.saxon.dom.NodeOverNodeInfo.cloneNode(NodeOverNodeInfo.java:395) at requester.Result.buildResultTree(Result.java:70) at requester.Result.loadXMLElements(Result.java:43) at requester.Request.mergeResults(Request.java:76) at requester.Request.<init>(Request.java:38) at gui.BoobleFrame.newSearch(BoobleFrame.java:99) ... So my new question is : Is there a good way to copy XdmNode as DOM Node from one XML document to another? Regards, Bruno. 2009/11/1, bruno le hyaric <bruno.lehyaric@...>: > Hi, > > I have a new problem... > > I want to create some XdmNode myself in Java. So I look the API > documentation. > There is a constructor which take a parameter NodeInfo, and then I'm > searching which way is the most suitable to create this NodeInfo. > > To explain my problem further : > > I'm working on a search engine for XML document based on the Java > language. So I build an index which is a set of reverse lists like : > > word1 -> elementX, elementY > word2 -> elementZ > ... > > All my program use XdmNode to handle XML element (because of the > equal() method). > > To render the result of a search I develop a little XSLT and now I > want to run this XSLT using the s9api with XdmNode as input/output... > > I just want to create a result XML tree like this : > > <results words="..." time="..."> > <result> ... > </result> > <result> ... > </result> > <result>... > </result> > </results> > > And so I need to create XdmNode for <results /> and <result />. > > > Regards, > > Bruno. > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: How to manually create XdmNode?> I found a first-step solution. I simply use the Java DOM
> implementation to create the document tree... but I have to > insert XdmNode in it and these XdmNodes come from other XML > documents... This doesn't look like a promising way forward at all. Saxon doesn't play well with the DOM. It's best to treat Saxon nodes as immutable. (Some tree models implement MutableNodeInfo, but that's only to support XQuery Update). I'm afraid it's not clear to me what you're trying to do. I can't relate your second message to your first one. Regards, Michael Kay http://www.saxonica.com/ http://twitter.com/michaelhkay > > > So I try to use the cloneNode() method like this : > > NodeOverNodeInfo.wrap(xdmNode.getUnderlyingNode()).cloneNode(true); > > and I get the exception : > > Exception in thread "AWT-EventQueue-0" > java.lang.UnsupportedOperationException: The Saxon DOM cannot > be updated > at > net.sf.saxon.dom.NodeOverNodeInfo.disallowUpdate(NodeOverNodeI > nfo.java:687) > at > net.sf.saxon.dom.NodeOverNodeInfo.cloneNode(NodeOverNodeInfo.java:395) > at requester.Result.buildResultTree(Result.java:70) > at requester.Result.loadXMLElements(Result.java:43) > at requester.Request.mergeResults(Request.java:76) > at requester.Request.<init>(Request.java:38) > at gui.BoobleFrame.newSearch(BoobleFrame.java:99) > ... > > > So my new question is : Is there a good way to copy XdmNode > as DOM Node from one XML document to another? > > > > Regards, > > Bruno. > > 2009/11/1, bruno le hyaric <bruno.lehyaric@...>: > > Hi, > > > > I have a new problem... > > > > I want to create some XdmNode myself in Java. So I look the API > > documentation. > > There is a constructor which take a parameter NodeInfo, and > then I'm > > searching which way is the most suitable to create this NodeInfo. > > > > To explain my problem further : > > > > I'm working on a search engine for XML document based on the Java > > language. So I build an index which is a set of reverse lists like : > > > > word1 -> elementX, elementY > > word2 -> elementZ > > ... > > > > All my program use XdmNode to handle XML element (because of the > > equal() method). > > > > To render the result of a search I develop a little XSLT and now I > > want to run this XSLT using the s9api with XdmNode as > input/output... > > > > I just want to create a result XML tree like this : > > > > <results words="..." time="..."> > > <result> ... > > </result> > > <result> ... > > </result> > > <result>... > > </result> > > </results> > > > > And so I need to create XdmNode for <results /> and <result />. > > > > > > Regards, > > > > Bruno. > > > > -------------------------------------------------------------- > ---------------- > Come build with us! The BlackBerry(R) Developer Conference in > SF, CA is the only developer event you need to attend this > year. Jumpstart your developing skills, take BlackBerry > mobile applications to market and stay ahead of the curve. > Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > saxon-help mailing list archived at > http://saxon.markmail.org/ saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
| Free embeddable forum powered by Nabble | Forum Help |