xsl-list
[Top] [All Lists]

RE: XSLT 2 processing of W3C Schema expressed default attributes

2003-09-02 09:50:34
Saxon is not (yet) a schema-aware processor: it takes its input from the
infoset, not from the PSVI. So it doesn't know anything about defaults
in the schema. There might be a way of invoking Saxon using (say) Xerces
in such a way that the defaults are expanded, but I'm not aware of it.

This raises an interesting point about the spec. Technically, everything
to do with construction of the source tree is outside the conformance
boundary. But in the discussion of the processing model, we probably
ought at least to mention that a schema-aware processor is more likely
to use the PSVI-to-datamodel mapping (and therefore to expand
schema-specified defaults) whereas a non-schema-aware processor is more
likely to use the infoset-to-datamodel mapping (and therefore to not
expand them).

Michael Kay


-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
G. Ken Holman
Sent: 02 September 2003 16:24
To: XSL List
Subject: [xsl] XSLT 2 processing of W3C Schema expressed 
default attributes


Hi folks!

My expectations of the instance and document model below are that a 
schema-aware XSLT 2 processor will "see" the default 
attribute expressed in 
the W3C Schema expression and this attribute will show up in 
a copy-of for 
the entire document.  I'm expecting the output <entry1> will have 
defattr="hello" included since I didn't specify such an 
attribute in the input.

The output running Saxon 7.6.5 doesn't show the default 
attribute and the 
documentation at 
http://saxon.sourceforge.net/saxon7.6.5/index.html doesn't 
discuss the PSVI, so I'm assuming I've messed up somewhere in the 
specification of the schema model ... but cannot see it in 
this simple 
example.

Can someone point me to where my mistake is and to which 
collection of XSLT 
2 processors I can work with to see these default attributes?

Thanks for your help!

.................. Ken

V:\samp>type defattr.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:noNamespaceSchemaLocation="defattr.wxd">
   <entry1>AB</entry1>
   <entry2 attr="CD"/>
</doc>

V:\samp>type defattr.wxd
<?xml version="1.0" encoding="iso-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>

<xsd:element name="doc">
   <xsd:complexType>
     <xsd:sequence>
       <xsd:element name="entry1">
         <xsd:complexType>
           <xsd:simpleContent>
             <xsd:extension base="codelist">
               <xsd:attribute name="defattr" 
type="xsd:string" use="optional"
                              default="hello"/>
             </xsd:extension>
           </xsd:simpleContent>
         </xsd:complexType>
       </xsd:element>
       <xsd:element name="entry2">
         <xsd:complexType>
           <xsd:attribute name="attr" type="codelist"/>
         </xsd:complexType>
       </xsd:element>
     </xsd:sequence>
   </xsd:complexType>
</xsd:element>

<xsd:simpleType name="codelist">
   <xsd:restriction base="xsd:normalizedString">
     <xsd:enumeration value="AB"/>
     <xsd:enumeration value="CD"/>
   </xsd:restriction>
</xsd:simpleType>

</xsd:schema>

V:\samp>msv defattr.wxd defattr.xml
No validation errors.

V:\samp>type copyofall2.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 version="2.0">

<xsl:template match="/">
   <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>
V:\samp>xslt2 defattr.xml copyofall2.xsl con
<?xml version="1.0" encoding="UTF-8"?><doc 
xsi:noNamespaceSchemaLocation="defatt
r.wxd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
   <entry1>AB</entry1>
   <entry2 attr="CD"/>
</doc>
V:\samp>


--
Next public European delivery:  3-day XSLT/2-day XSL-FO 
2003-09-22 Instructor-led on-site corporate, government & 
user group training for XSLT and XSL-FO world-wide:  please 
contact us for the details

G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list