You haven't said which XSLT processor you are using, or how you are invoking
it.
If you run with Saxon as your XSLT processor, and invoke schema validation
using Saxon interfaces (for example, using -val:strict on the command line)
then default attributes will be expanded (unless you explicitly request for
them not to be expanded).
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: Trevor Nicholls [mailto:trevor(_at_)castingthevoid(_dot_)com]
Sent: 28 September 2009 15:45
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Fixed attribute problems on change from DTD to schema
Hi
As previously described I have switched from DTD modelling to
XSD for my application's XML files. Today I have encountered
a problem with default/fixed attribute values: the fixed
attribute value appears to be forced into the parsed XML file
when using the DTD (as wanted) but apparently not found when
using the schema.
Document 1:
----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document system "hcdocs.dtd">
<document>
<title>Software development</title>
<section>
<title id="Head">Q.A. Cycle</title>
<steps>
<step>Test application</step>
<step>Isolate problem</step>
<step>Submit bug report</step>
<step>Wait a while</step>
<step>When anything happens, go back to step 1</step>
</steps> </section> </document>
----
and Document 2:
----
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="hcdocs.xsd">
<title>Software development</title>
<section>
<title id="Head">Q.A. Cycle</title>
<steps>
<step>Test application</step>
<step>Isolate problem</step>
<step>Submit bug report</step>
<step>Wait a while</step>
<step>When anything happens, go back to step 1</step>
</steps> </section> </document>
----
In the DTD, the section element is defined like so:
----
<!ELEMENT section (title, (section|para|steps)*)> <!ATTLIST section
mark CDATA "Y"
break (Y|N) #IMPLIED
----
and in the schema, like so:
----
<xs:complexType name="sectionaltype">
<xs:sequence>
<xs:element ref="title"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="section"/>
<xs:element ref="para"/>
<xs:element ref="steps"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:element name="section">
<xs:complexType>
<xs:complexContent>
<xs:extension base="sectionaltype">
<xs:attribute name="break">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Y"/>
<xs:enumeration value="N"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="mark" fixed="Y"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
----
The documents are passed into a stylesheet which includes these two
templates:
----
<xsl:template match="*[(_at_)mark='Y']" priority="2"> ...
</xsl:template>
<xs:template match="*">
...
</xsl:temnplate>
----
Unlike my earlier problems, I am not compelled to use Xalan
for this transformation, and it is (mis)behaving as described
when the processor is
Saxon:
* the section in document 1 is matched by the first template;
* the section in document 2 is matched by the second template.
I would expect both documents to give the same result (and
use template 1 for sections).
Can somebody please explain why this is happening? The
commandline is identical for the two cases, no options are
being supplied either to suppress or to force attribute value
inheritance from the DTD/schema.
Thanks
Trevor
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--