[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Request help in understanding: node instance of sche

Subject: 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
 Request help in understanding:  node instance of  sche
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.