Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
XML
How to pull the namespaces to the serailized XML Fragment using Xalan-C++ API
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="lanegroups, post: 2024173"] Dear experts, I'm trying to do the following using Xalan-C++ API 1. parse an XML document 2. evaluate an XML path 3. serialize the selected XML subtree 4. The new serialized XML fragment should have the correct namespace declared, based on their declaration from the original XML document. Task 1-3 are done and I'm using the traverseSubtree method from FormatterTreeWalker class to serialize the subtree. However, the namespace declaration is not put in the new root element by the traverseSubtree method. For example, <doc xmlns:ns1="[URL]http://www.one.com[/URL]" xmlns:ns2="[URL]http://www.two.com[/URL]" xmlns:ns3="[URL]http://www.three.com[/URL]" xmlns="[URL]http://www.default.com[/URL]"> <ns1:element1> <ns2:element2> <ns3:element3>123</ns3:element3> </ns2:element2> </ns1:element1> </doc> After evaluating xpath "'/default:doc/ns1:element1/ns2:element2/ns3:element3" I can get the serialized fragment as <ns3:element3>123</ns3:element3> I want to get something below <ns3:element3 xmlns:ns3="[URL]http://www.three.com[/URL]" xmlns="[URL]http://www.default.com[/URL]">123</ns3:element3> or <ns3:element3 xmlns:ns1="[URL]http://www.one.com[/URL]" xmlns:ns2="[URL]http://www.two.com[/URL]" xmlns:ns3="[URL]http://www.three.com[/URL]" xmlns="[URL]http://www.default.com[/URL]">123</ns3:element3> I think I can travese the tree again to collect the namespace URIs and prefixes and generate the string in the root, but that's not effecient. Are there existing Xalan C++ APIs that can handle this already? For example, are there Xalan C++ APIs that I can retrieve the related namespace URIs and prefixes based on the context? Thanks a lot in advance!! [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
XML
How to pull the namespaces to the serailized XML Fragment using Xalan-C++ API
Top