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 Neil Aggarwal <ne...@JAMMConsulting.com> on 2006/08/04 23:36:05 UTC

Tell OutputFormat to use close tags

Hello:

I am using XMLSerializer with OutputFormat to format
my XML into a string using this code:

    /* document contains a Document object */

    CharArrayWriter writer = new CharArrayWriter();
    OutputFormat outputFormat = new OutputFormat("xml","utf-8",true);
    XMLSerializer serializer = new XMLSerializer(writer,outputFormat);
    serializer.serialize(document);
    writer.close();

    /* writer.toString() gives me the XML formatted in a string */

When the text content of a tag is empty, I am getting
this in the output:
	
	<TagName/>

I would like to generate this output instead:
	<TagName></TagName>

Any ideas?

I know the first form is correct and conformant, but I don't control
the other side's parsing code.

Thanks,
	Neil

--
Neil Aggarwal, (214)986-3533, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.


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


Re: Serializing an XSModel to a set of XML Schema documents

Posted by Stéphane Mbaye <st...@gael.fr>.
Many thanks for this quick support

Michael Glavassevich wrote:
> Dick Deneer <di...@donkeydevelopment.com> wrote on 11/13/2006 
> 06:02:59 AM:
>
>   
>> I have not seen this in Xerces.
>>     
>
> Right. XSModel is read-only and there's currently no method for 
> serializing one.
>
>   
>> But  I know the xsd framework from the Eclipse project, see http:// 
>> www.eclipse.org/xsd/,   has the fucntionality to build a XSModel in 
>> memory and serialize it to a xsd.
>>
>> Op 13-nov-2006, om 0:38 heeft Stéphane Mbaye het volgende geschreven:
>>
>>     
>>> Hello everyone,
>>>
>>> is their any means to serialize one ore more XML Schema documents 
>>> from an XSModel implementing class? I am looking for a way for re- 
>>> arranging XML Schema contents and document deployments from the XML 
>>> Schema API's point of view (and in particular if the XSModel does 
>>> not originate from input files but has been dynamically generated).
>>>
>>> Ideally, more than serializing the XSModel to an output stream, it 
>>> could be converted to a DOM tree.
>>>
>>> Thanks in advance
>>> Stéphane
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>     
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
>   


Re: Serializing an XSModel to a set of XML Schema documents

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Dick Deneer <di...@donkeydevelopment.com> wrote on 11/13/2006 
06:02:59 AM:

> I have not seen this in Xerces.

Right. XSModel is read-only and there's currently no method for 
serializing one.

> But  I know the xsd framework from the Eclipse project, see http:// 
> www.eclipse.org/xsd/,   has the fucntionality to build a XSModel in 
> memory and serialize it to a xsd.
> 
> Op 13-nov-2006, om 0:38 heeft Stéphane Mbaye het volgende geschreven:
> 
> > Hello everyone,
> >
> > is their any means to serialize one ore more XML Schema documents 
> > from an XSModel implementing class? I am looking for a way for re- 
> > arranging XML Schema contents and document deployments from the XML 
> > Schema API's point of view (and in particular if the XSModel does 
> > not originate from input files but has been dynamically generated).
> >
> > Ideally, more than serializing the XSModel to an output stream, it 
> > could be converted to a DOM tree.
> >
> > Thanks in advance
> > Stéphane
> >
> > ---------------------------------------------------------------------
> > 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

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


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


Re: Serializing an XSModel to a set of XML Schema documents

Posted by Dick Deneer <di...@donkeydevelopment.com>.
I have not seen this in Xerces.
But  I know the xsd framework from the Eclipse project, see http:// 
www.eclipse.org/xsd/,   has the fucntionality to build a XSModel in  
memory and serialize it to a xsd.

Op 13-nov-2006, om 0:38 heeft Stéphane Mbaye het volgende geschreven:

> Hello everyone,
>
> is their any means to serialize one ore more XML Schema documents  
> from an XSModel implementing class? I am looking for a way for re- 
> arranging XML Schema contents and document deployments from the XML  
> Schema API's point of view (and in particular if the XSModel does  
> not originate from input files but has been dynamically generated).
>
> Ideally, more than serializing the XSModel to an output stream, it  
> could be converted to a DOM tree.
>
> Thanks in advance
> Stéphane
>
> ---------------------------------------------------------------------
> 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


Serializing an XSModel to a set of XML Schema documents

Posted by Stéphane Mbaye <st...@gael.fr>.
Hello everyone,

is their any means to serialize one ore more XML Schema documents from 
an XSModel implementing class? I am looking for a way for re-arranging 
XML Schema contents and document deployments from the XML Schema API's 
point of view (and in particular if the XSModel does not originate from 
input files but has been dynamically generated).

Ideally, more than serializing the XSModel to an output stream, it could 
be converted to a DOM tree.

Thanks in advance
Stéphane

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


Re: Tell OutputFormat to use close tags

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Neil,

"Neil Aggarwal" <ne...@JAMMConsulting.com> wrote on 08/04/2006 05:36:05 PM:

> Hello:
> 
> I am using XMLSerializer with OutputFormat to format
> my XML into a string using this code:
> 
>     /* document contains a Document object */
> 
>     CharArrayWriter writer = new CharArrayWriter();
>     OutputFormat outputFormat = new OutputFormat("xml","utf-8",true);
>     XMLSerializer serializer = new XMLSerializer(writer,outputFormat);
>     serializer.serialize(document);
>     writer.close();
> 
>     /* writer.toString() gives me the XML formatted in a string */
> 
> When the text content of a tag is empty, I am getting
> this in the output:
> 
>    <TagName/>
> 
> I would like to generate this output instead:
>    <TagName></TagName>
> 
> Any ideas?

The serializer will always write an element without content as an empty 
tag. There's no configuration parameter for changing that behaviour though 
I suppose you could try fooling the serializer into believing there is 
content by attaching empty text nodes to each element you want written as 
<TagName></TagName>.

> I know the first form is correct and conformant, but I don't control
> the other side's parsing code.
> 
> Thanks,
>    Neil
> 
> --
> Neil Aggarwal, (214)986-3533, www.JAMMConsulting.com
> FREE! Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

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

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