Subject: RE: [xsl] Fixed attribute problems on change from DTD to schema From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 28 Sep 2009 20:43:46 +0100 |
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@xxxxxxxxxxxxxxxxxx] > Sent: 28 September 2009 15:45 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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="*[@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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Fixed attribute problems , Kendall Shaw | Thread | [xsl] xsl-for-each-group in xslt 2., a kusa |
Re: [xsl] Help XSL Transformation o, Rajesh Jain | Date | [xsl] XSL-FO beginner's question, mark bordelon |
Month |