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

RE: How to check an element's type against an XSD sim

Subject: RE: How to check an element's type against an XSD simpleType and skip that element if it does not conform to the simpleType?
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Tue, 16 Jul 2013 12:44:01 +0000
RE:  How to check an element's type against an XSD  sim
Hi David,

> If the input hasn't been validated you can just get the text content of
> the node and check
>
> <xsl:if test=". castable as bk:ISBN-type">

But **bk:ISBN-type** is a simpleType defined in the XML Schema; so I have to
import the XML Schema:

    <xsl:import-schema namespace="http://www.books.org"
        schema-location="BookStore.xsd"/>

But then I am back to the problem of the XSLT processor insisting on
validating all of my XML document.

Is there a way to get access to the simpleType, ISBN-type, without importing
the XML Schema?

/Roger

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Tuesday, July 16, 2013 8:29 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: Costello, Roger L.
Subject: Re:  How to check an element's type against an XSD simpleType
and skip that element if it does not conform to the simpleType?

On 16/07/2013 13:07, Costello, Roger L. wrote:
> Michael Kay wrote:
>
>> Unfortunately schema-aware processing in XQuery and XSLT doesn't
>> give you this capability.
>
> Is there a workaround?
>
> Is there is no way for an XSLT program to express: "Hey, validate xyz
> against the XML Schema and if xyz is not schema-valid then discard
> it." No way to express that?
>

Can't you just not validate the input, then test within the stylesheet
as you are testing an atomic/simple type.



> <xsl:if test=". instance of bk:ISBN-type">

If the input hasn't been validated you can just get the text content of
the node and check

<xsl:if test=". castable as bk:ISBN-type">

Or of course you could more simply in this case not import the schema
and just check the regular expression directly in the stylesheet (then
it will work with non schema aware systems too)

David

________________________________________________________________________
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.