You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Heinrich Roman <ro...@telekom.at> on 2008/03/06 13:55:50 UTC

DOM document serialization question

Hello,

I have an DOM document, which I want to serialize and I want also to
attach xsd document inside the generated xml.

The ouput should be like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
 <orderperson>John Smith</orderperson>
 <shipto>
  <name>Ola Nordmann</name>
  <address>Langgt 23</address>
  <city>4000 Stavanger</city>
  <country>Norway</country>
 </shipto>
 <item>
  <title>Empire Burlesque</title>
  <note>Special Edition</note>
  <quantity>1</quantity>
  <price>10.90</price>
 </item>
 <item>
  <title>Hide your heart</title>
  <quantity>1</quantity>
  <price>9.90</price>
 </item>
</shiporder>

Or it`s possible to have shiporder.xsd direct inside xml ?

Can anybody provide me with an example ?

Thanks.

Re: AW: DOM document serialization question

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
If it isn't already in the DOM try adding it to the root element using
setAttributeNS() [1] before you serialize.

[1]
http://xerces.apache.org/xerces2-j/javadocs/api/org/w3c/dom/Element.html#setAttributeNS(java.lang.String,%20java.lang.String,%20java.lang.String)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Heinrich Roman" <ro...@telekom.at> wrote on 03/06/2008 08:58:52
AM:

> Either attaching  xsi:noNamespaceSchemaLocation or directly
> embedding xsd schema to xml.
>
>
> -----Ursprüngliche Nachricht-----
> Von: Michael Glavassevich [mailto:mrglavas@ca.ibm.com]
> Gesendet: Donnerstag, 06. März 2008 14:57
> An: j-users@xerces.apache.org
> Betreff: Re: DOM document serialization question
>
> By attach do you mean adding the 'xsi:noNamespaceSchemaLocation'
> attribute to the root element of your document?
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> "Heinrich Roman" <ro...@telekom.at> wrote on 03/06/2008 07:55:50
> AM:
>
> > Hello,
> > I have an DOM document, which I want to serialize and I want also to
> > attach xsd document inside the generated xml.
> > The ouput should be like this:
> > <?xml version="1.0" encoding="ISO-8859-1"?> <shiporder
> > orderid="889923"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:noNamespaceSchemaLocation="shiporder.xsd">
> >  <orderperson>John Smith</orderperson>  <shipto>
> >   <name>Ola Nordmann</name>
> >   <address>Langgt 23</address>
> >   <city>4000 Stavanger</city>
> >   <country>Norway</country>
> >  </shipto>
> >  <item>
> >   <title>Empire Burlesque</title>
> >   <note>Special Edition</note>
> >   <quantity>1</quantity>
> >   <price>10.90</price>
> >  </item>
> >  <item>
> >   <title>Hide your heart</title>
> >   <quantity>1</quantity>
> >   <price>9.90</price>
> >  </item>
> > </shiporder>
> > Or it`s possible to have shiporder.xsd direct inside xml ?
> > Can anybody provide me with an example ?
> > Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


AW: DOM document serialization question

Posted by Heinrich Roman <ro...@telekom.at>.
Either attaching  xsi:noNamespaceSchemaLocation or directly embedding xsd schema to xml.


-----Ursprüngliche Nachricht-----
Von: Michael Glavassevich [mailto:mrglavas@ca.ibm.com] 
Gesendet: Donnerstag, 06. März 2008 14:57
An: j-users@xerces.apache.org
Betreff: Re: DOM document serialization question

By attach do you mean adding the 'xsi:noNamespaceSchemaLocation' attribute to the root element of your document?

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Heinrich Roman" <ro...@telekom.at> wrote on 03/06/2008 07:55:50
AM:

> Hello,
> I have an DOM document, which I want to serialize and I want also to 
> attach xsd document inside the generated xml.
> The ouput should be like this:
> <?xml version="1.0" encoding="ISO-8859-1"?> <shiporder 
> orderid="889923"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="shiporder.xsd">
>  <orderperson>John Smith</orderperson>  <shipto>
>   <name>Ola Nordmann</name>
>   <address>Langgt 23</address>
>   <city>4000 Stavanger</city>
>   <country>Norway</country>
>  </shipto>
>  <item>
>   <title>Empire Burlesque</title>
>   <note>Special Edition</note>
>   <quantity>1</quantity>
>   <price>10.90</price>
>  </item>
>  <item>
>   <title>Hide your heart</title>
>   <quantity>1</quantity>
>   <price>9.90</price>
>  </item>
> </shiporder>
> Or it`s possible to have shiporder.xsd direct inside xml ?
> Can anybody provide me with an example ?
> Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: DOM document serialization question

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
By attach do you mean adding the 'xsi:noNamespaceSchemaLocation' attribute
to the root element of your document?

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Heinrich Roman" <ro...@telekom.at> wrote on 03/06/2008 07:55:50
AM:

> Hello,
> I have an DOM document, which I want to serialize and I want also to
> attach xsd document inside the generated xml.
> The ouput should be like this:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <shiporder orderid="889923"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="shiporder.xsd">
>  <orderperson>John Smith</orderperson>
>  <shipto>
>   <name>Ola Nordmann</name>
>   <address>Langgt 23</address>
>   <city>4000 Stavanger</city>
>   <country>Norway</country>
>  </shipto>
>  <item>
>   <title>Empire Burlesque</title>
>   <note>Special Edition</note>
>   <quantity>1</quantity>
>   <price>10.90</price>
>  </item>
>  <item>
>   <title>Hide your heart</title>
>   <quantity>1</quantity>
>   <price>9.90</price>
>  </item>
> </shiporder>
> Or it`s possible to have shiporder.xsd direct inside xml ?
> Can anybody provide me with an example ?
> Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org