Vitaly Prapirny <[email protected]> wrote on 08/30/2010 04:12:09 AM:

> Thank you for the answer.
>
> So "whiteSpace='preserve'" facet could not preserve any line feed in an
> attribute's value. Am I understanding this right?

That's not what I said. :-)

whiteSpace='preserve' does a fine job at preserving line feeds if they were
in the attribute's [normalized value] [1]. The way you've written the
document the line feeds get normalized by the XML parser before they hit
the schema validator. If you actually want a line feed to be included in
the content of an attribute value you need to encode it (e.g. &#xA;).

> Good luck!
>    Vitaly
>
> Michael Glavassevich wrote:
> > Vitaly,
> >
> > XML parsers are required to normalize [1] attribute values. The line
feed
> > would be substituted with a space (i.e. 0x20) before the schema
validator
> > sees it.
> >
> > Thanks.
> >
> > [1] http://www.w3.org/TR/2006/REC-xml-20060816/#AVNormalize
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: [email protected]
> > E-mail: [email protected]
> >
> > Vitaly Prapirny<[email protected]>  wrote on 08/27/2010 10:50:13 AM:
> >
> >> Greetings,
> >>
> >>     Could someone please enlighten me on why these document had been
> >> validated without error? Shouldn't the line feed be preserved when
> >> validating the 'd' attribute so that the pattern check fails?
> >>
> >> ======= b.xml =============
> >> <?xml version="1.0"?>
> >> <e xmlns="e" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >> xsi:schemaLocation="e a.xsd" d="k
> >> "/>
> >> ===========================
> >> ======= a.xsd =============
> >> <?xml version="1.0"?>
> >> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:e="e"
> >> targetNamespace="e">
> >>     <xs:simpleType name="a">
> >>        <xs:restriction base="xs:string">
> >>           <xs:pattern value="[&#x0020;]*[&#x0021;-&#x007E;][&#x0020;-
> >> &#x007E;]*"/>
> >>           <xs:whiteSpace value="preserve"/>
> >>        </xs:restriction>
> >>     </xs:simpleType>
> >>     <xs:complexType name="c">
> >>               <xs:attribute name="d" type="e:a">
> >>               </xs:attribute>
> >>     </xs:complexType>
> >>     <xs:element name="e" type="e:c"/>
> >> </xs:schema>
> >> ===========================
> >>
> >> Good luck!
> >>     Vitaly

Thanks.:

[1] http://www.w3.org/TR/xml-infoset/#infoitem.attribute:

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [email protected]
E-mail: [email protected]

Reply via email to