Re: XmlSerialzier
Stefan Haustein <[email protected]>
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Organization | Univ. Dortmund FB 4 LS 8 |
| Message-ID | <[email protected]> |
> hi,
>
> i think that call to setPrefix("pref", ...) should always result in delcaring prefix namespace
> i.e. for XML 1.0 in xmlns:prefix='...' and similarly to change or declre default namespace
> simple call setPrefix("", "...") could be used (resulting in xmlns='') - so calling setPrefix("", "")
> would always restore default namespace (setting it to 'no namespace' state of '').
yes, but for consitency with the parser, "no prefix" should be
"null"; but then, for getPrefix we have a problem: What to return
from getPrefix (namespace) in the case of
- no prefix defined vs.
- no prefix; given namespace is default namespace?
Best,
Stefan
>
> so setPrefix("", "urn:namespace") can be used to change default namespace but there is
> a potential problem: when startTag() is to be serialized with default namesapce
> (ex. startTag("", "foo")) then XmlSerializer has no way to generate prefix for default namespace
> (serializing "xnlns:n1=''" is illegal and when parsed by XML 1.0 with namespaces compliant
> parser will result in exception).
>
> so i think that in this case the generated prefix must be used for "urn:namespace"
> (if no prefix for "urn:namespace" is available) and default namespace must be restored to ""
> to be able to write startTag that is in default namespace.
>
> finally attributes can not be declared in default namespace so calling attribute("", "attrName", "value")
> will always result in serializing an attribute without namespace and there is no need to find or declare
> prefix for it (in XML 1.0 just simply write "attrName=''").
>
> here is an example of how it could work:
>
> startTag("", "foo")
> setPrefix("", "urn:namespace"); //chnage default namespae
> startTag("unr:namespace", "quo")
> startTag("", "bar"); // as defult nemspace is not '' this implicitly causes: setPrefix("", ""),
> setPrefix(NEW, "urn:namespace")
> attribute("", "attrName", "value")
> attribute("urn:namespace", "attr2", "value")
> startTag("", "baz")
> startTag("urn:namespace", "zoo")
>
> that i think should be serialized as:
>
> <foo>
> <quo xmlns='urn:namespace'>
> <bar xmlns="" xmlns:n1="urn:namespace" attrName='value' n1:atttr='value'>
> <baz>
> <n1:zoo>
>
> does it sound reasonable?
>
> thanks,
>
> alek
>
>
>
>
> 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/
>
>
--
Stefan Haustein
Univ. Dortmund, FB 4, LS 8 tel: +49 231 755 2499
Baroper Str. 301 fax: +49 231 755 5105
D-44221 Dortmund (Germany) www-ai.cs.uni-dortmund.de