Call to Java function returning XML content.
Added by Anonymous over 17 years ago
Legacy ID: #4224261 Legacy Poster: popol (mrjeje)
Hello, I post a second message since this concerns a new problem I have using external Java functions. I still use an external Java function that returns an XML formatted string. My query: declare namespace mine="java:Test"; <root> { let $myXml := mine:test('myString') return $myXml } </root> The 'test' method (contained in a Test.java class) is static and return the 'myString' string in an xml container like: <anyTag>myString</anyTag> When I retrieve the result string after the query execution, all '<' and '>' characters are escaped like this: <root> <anyTag>myString</anyTag> </root> I tried to change the output properties by changing the OutputKeys.METHOD set to 'text'. In this case, the characters are not escaped but the 'root' start/end tags are not returned by the query. Are there any way to have in my case a complete XML string as result of my query execution without any espaced characters like: <root> <anyTag>myString</anyTag> </root> I was wondering what I was doing wrong ? Thanks in advance, Jérôme.
Replies (2)
RE: Call to Java function returning XML conte - Added by Anonymous over 17 years ago
Legacy ID: #4224264 Legacy Poster: popol (mrjeje)
Sorry for posting it twice. Hopefully, this is week-end. Jérôme.
RE: Call to Java function returning XML conte - Added by Anonymous over 17 years ago
Legacy ID: #4224438 Legacy Poster: Michael Kay (mhkay)
I have lost track of your different questions. If you return unparsed XML such as "<a>bb</a>" from a function then Saxon doesn't know that the angle brackets are markup, it treats them as character data which means they will be output as &_lt; etc. (ignore the underscore). You can solve that by parsing the XML either from your Java code or (using saxon:parse) from your XQuery code, as you did in your other example. You don't need then to serialize it, because serialize(parse(x)) effectively gives you x, which is back where you started.
Please register to reply