On Sun, Feb 19, 2012 at 4:44 PM, Andreas Veithen <[email protected]>wrote:
> The XML spec only describes what an XML parser must do before passing > an attribute value to the application. However, it doesn't specify how > an XML serializer should handle an attribute value received from the > application and that is not normalized. Axiom doesn't specify that > either. It simply passes the value to the StAX implementation. Your > example shows that the StAX implementation (Woodstox I guess) chooses > to serialize the newline character as a character reference (
). > Probably the rationale is that this ensures that the receiving > application gets exactly the same string as the one passed to the > serializer, i.e. it maximizes the round-trippability for attribute > values. > > Yes, I understand the value of keeping the it as it is. I was concerned about axiom vs xml spec. I did some testing, yes parsing works as expected. Thank you for the clarification. --Kasun Andreas > > On Sat, Feb 18, 2012 at 14:13, Kasun Gajasinghe <[email protected]> wrote: > > Hi, > > > > I have a question regarding how Axiom normalize attribute values. Say I > > added an attribute to a document that has a newline character (\n or > #xA) > > in the attribute value to a built OMDocument, and then serialize it. Now > > doesn't the serialized content supposed to replace the newline character > by > > a space character (#x20) as of [1] 3.3 bullet point? Or am I looking at > two > > different things? Understanding how axiom behaves in these situations is > > crucial when it comes to serializing etc. > > > > Here's a code snippet of a test I did. > > > > documentElement.addAttribute("attrName", " \n attVal ", null); > > documentElement.serialize(System.out); > > > > The serialized xml contains - attrName=" 
 attVal ". But I think > it > > should be "   attVal ". > > > > [1] http://www.w3.org/TR/REC-xml/#AVNormalize > > > > Thanks for any help! > > --Kasun > > > > -- > > ~~~*******'''''''''''''*******~~~ > > Kasun Gajasinghe > > Software Engineer; WSO2 Inc.; http://wso2.com > > > > , > > Linked-in: http://lk.linkedin.com/in/gajasinghe > > blog: http://blog.kasunbg.org > > > > > > twitter: http://twitter.com/kasunbg > > > -- ~~~*******'''''''''''''*******~~~ *Kasun Gajasinghe* Software Engineer; WSO2 Inc.; http://wso2.com , *Linked-in: *http://lk.linkedin.com/in/gajasinghe* * *blog: **http://blog.kasunbg.org* <http://blog.kasunbg.org/> * twitter: **http://twitter.com/kasunbg* <http://twitter.com/kasunbg>
