Subject: [xsl] Request help in understanding: node instance of schema-element(node) From: "Costello, Roger L." <costello@xxxxxxxxx> Date: Sat, 26 Jan 2008 16:59:18 -0500 |
Hi Folks, Apparently I am not correctly understanding this XPath statement: if (//test instance of schema-element(test)) then //test * 2 else 'Error' My understanding of the XPath is this: "If the <test> element in the input document conforms to the declaration of test in the XML Schema then multiply its value by 2, otherwise output Error." I have an XML Schema in which I declare the <test> element. The <test> element in the input XML document conforms to the Schema declaration. So, I expected the XPath statement to execute the if-statement. Instead, it executes the else-statement. Thus, the output is: Error. What am I doing wrong? I am using the schema-aware version of SAXON, version 8.9.0.4j. Below is the stylesheet, XML Schema, and XML document. Any help would be much appreciated. /Roger ---------------------------------------------------------- STYLESHEET (test.xsl) <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text"/> <xsl:import-schema schema-location="test.xsd"/> <xsl:template match="/"> <xsl:value-of select="if (//test instance of schema-element(test)) then //test * 2 else 'Error'"/> </xsl:template> </xsl:stylesheet> ---------------------------------------------------------- XML SCHEMA (test.xsd) <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="test" type="xs:integer"/> </xs:schema> ---------------------------------------------------------- XML DOCUMENT (test.xml) <?xml version="1.0" encoding="UTF-8"?> <test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd"> 120 </test>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Copy Child Elements, Rick Quatro | Thread | RE: [xsl] Request help in understan, Michael Kay |
Re: [xsl] combining multiple docume, Steven Ericsson-Zeni | Date | RE: [xsl] Request help in understan, Michael Kay |
Month |