Re: XMLSerializer and default namespaces

Iain Shigeoka <[email protected]>
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <BA692A9B.136E2%[email protected]>
On 2/5/03 21:25, "Aleksander Slominski" <[email protected]> wrote:

> Iain Shigeoka wrote:
> 
>> I've been using the XMLSerializer and really enjoy the API. The only feature
>> that I feel would be really helpful is some way to tell the serializer that
>> I'd prefer a certain start tag namespace declaration be a default namespace
>> declaration rather than have it generate and use a prefix for itself and all
>> children.
>> 
> hi,
> 
> this is not immediately obvious but you can do it already: set default
> namespace by binding
> namespace to prefix that is empty string, see last note in javadoc
> description of :setPrefix():
> 
> http://www.xmlpull.org/v1/doc/api/org/xmlpull/v1/XmlSerializer.html#setPrefix(
> java.lang.String,%20java.lang.String)
> 
> and find below a simple sample to demonstrate use of it. - when you run
> this sample
> you should see output similar to this:
> 
> serializer implementation class is class
> org.xmlpull.mxp1_serializer.MXSerializer
> serializer output: <foo
> xmlns="http://examlple.com/sample/namespace">bar</foo>

Thanks, very cool.

>> The motivation is that some xml apps I deal with use their own, home grown
>> xml parsers that aren't namespace aware. So they will often only match the
>> bare tag name (prefixes throws them into a tizzy). This is most common with
>> J2ME midlets although I've seen some desktop apps doing the same.
>> 
> we all have sometimes to deal with imperfect XML - i can only sympathize
> with you :-)

:)

> ps. next verion of XPP3/MXP1 (MXSerializer) will support all optional
> serialzier properties and features  to give greater control on output
> formatting 
> (http://xmlpull.org/v1/doc/features.html#serializer-attvalue-use-apostrophe,
> http://xmlpull.org/v1/doc/properties.html#serializer-indentation,
> http://xmlpull.org/v1/doc/properties.html#serializer-line-separator)

Very nice. I was resorting to a DOM for pretty printing. This will be very
nice.

Thanks

-iain


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/2U_rlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.