Java XML Create Fragment/Elements Without Namespace -


i trying construct xml document using org.w3c.dom.document create xml existing tool. problem having tool seems have xml namespaces in strange way. how can replicate using java api's?

<ns1:myroot xmlns:ns1="http://foo.com/ns1/">   <ns2:bar xmlns:ns2="http://foo.com/xml/bar/">     <ns2:bar_thing>abc</ns2:bar_thing>   </ns2:bar>   <ns3:data xmlns:ns3="http://foo.com/xml/special-ns">     <!--these not namespaced reason. if use ns3 prefix, or       use default xmls="...", tool fails load document, saying       elements have invalid values.       -->       <a>element without namespace</a>       <b>         <bi>1</bi>         <bii>2</bii>       </b>   </ns3:data> </ns1:myroot> 

i can build of document createelementns , setattributens. can't ns3:data contents correct.

trying use non-namespace createelement still left xmlns="http://foo.com/xml/special-ns"> on a , b elements, did using createelementns empty namespace, , non-empty namespace puts them in namespace.

the schema http://foo.com/xml/special-ns has bunch of declarations these below, not sure tns thing about, otherwise not seem special (although not 100% sure tool xsd , don't have access source).

<xs:schema version="1.0" targetnamespace="http://foo.com/xml/special-ns">   <!--bunch of xs:element such this-->   <xs:element name="data" type="tns:data" />    <!--types declared after-->   <xs:complextype name="data">     <xs:sequence>       <xs:element name="a" type="tns:adataobj" minoccurs="0"/>       <xs:element name="b" type="tns:bdataobj" minoccurs="0"/>     </xs:sequence>   </xs:complextype>    <xs:simpletype name="adataobj">     <xs:restriction base="xs:string">       <xs:pattern value="[a-za-z0-9 ]+" />     </xs:restriction>   </xs:simpletype>    <xs:complextype name="bdataobj">     <xs:sequence>       <xs:element name="bi" type="xs:string"/>       <xs:element name="bii" type="xs:string"/>     </xs:sequence>   </xs:complextype> </xs:schema> 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -