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

Re: How to compare two QName values in an XML Schema?

Subject: Re: How to compare two QName values in an XML Schema?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 08 Apr 2011 17:06:16 +0100
Re:  How to compare two QName values in an XML Schema?
On 08/04/2011 17:00, Costello, Roger L. wrote:
Hi Folks,

Below is an XML Schema, containing two simpleTypes. The second one references the first.

I want an XPath expression that compares the second simpleType's reference to the name of the first simpleType:


/xs:schema/xs:simpleType[1]/@name eq /xs:schema/xs:simpleType[2]/xs:restriction/@base


That returns False. I want it to return True.


I figured the reason it's returning False is because it is comparing the string "elev:BostonAreaSurfaceElevation" against the string "EarthSurfaceElevation". Yes?


one way is to use a schema aware xpath engine, if the two attributes are schema typed as QNames they will be compared as such.


otherwise you can extract the local name and uri associated with the prefix using in-scope-prefixes 9or the namespace axis if that is supported)

David


I want it to do a comparison of QNames, not strings. So I type-cast the values:


xs:QName(/xs:schema/xs:simpleType[1]/@name) eq xs:QName(/xs:schema/xs:simpleType[2]/xs:restriction/@base)


But that gave me this error:


Casting from xs:unTypedAtomic to xs:QName can never succeed.

Why?

What's the correct way to do the comparison?

---------------------------------------------------------
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             targetNamespace="http://www.elevation.org"
             xmlns:elev="http://www.elevation.org"
             elementFormDefault="qualified">

     <xsd:simpleType name= "EarthSurfaceElevation">
         <xsd:restriction base="xsd:integer">
             <xsd:minInclusive value="-1290"/>
             <xsd:maxInclusive value="29035"/>
         </xsd:restriction>
     </xsd:simpleType>

     <xsd:simpleType name= "BostonAreaSurfaceElevation">
         <xsd:restriction base="elev:EarthSurfaceElevation">
             <xsd:minInclusive value="0"/>
             <xsd:maxInclusive value="120"/>
         </xsd:restriction>
     </xsd:simpleType>

</xsd:schema>
---------------------------------------------------------

/Roger


________________________________________________________________________ This e-mail has been scanned for all viruses by Star. ________________________________________________________________________



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.