Re: [xsl] XPath 2.0 Best Practice: wrap the first node of every path expression within schema-element?

Subject: Re: [xsl] XPath 2.0 Best Practice: wrap the first node of every path expression within schema-element?
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 25 Mar 2008 18:02:40 +0100
Costello, Roger L. wrote:

Apparently, from what Martin states, AltovaXML is schema-aware but
would not generate an error or a warning on the above examples.
(Martin, can you confirm this?)

Yes, so far I have not been able to get AltovaXML to report errors or warnings on misspelled or not existing elements, even when the input document had been validated.


My test document is

<Book
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:noNamespaceSchemaLocation="test2008032101Xsd.xml">

  <Author>
    <LastName>Kay</LastName>
    <FirstName>Michael</FirstName>
  </Author>

</Book>

where the schema file looks like this

<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema";
  version="1.0">

  <xs:element name="Book">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Author" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="LastName" type="xs:string"/>
              <xs:element name="FirstName" type="xs:string"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>

and the XSLT stylesheet looks like this:

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="2.0">

<xsl:import-schema schema-location="test2008032101Xsd.xml"/>

<xsl:template match="/schema-element(Book)">
<xsl:text>matching on schema type: </xsl:text>
<xsl:value-of select="(Author/LastName, Author/Foo, Author/LastNam, Author/Firstname)"/>
</xsl:template>


</xsl:stylesheet>

then I run it like this

AltovaXML.exe /xslt2 test2008032101Xsl.xml /in test2008032101.xml

and the output is

<?xml version="1.0" encoding="UTF-8"?>matching on schema type: Kay

so it applies the template matching on schema-element(Book) but it does not give any warnings on Author/Foo, Author/LastNam, Author/Firstname.



--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread