[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 09:15:24 +0000
RE:  How to check an element's type against an XSD  sim
> You can use input-type-annotations="strip" so that your input tree
> has no type information (and thus won't be constrained by the schema).

Thanks Ken. That's really good to know. Okay, I added that to the top of my
XSLT program. I still get the same error. Below is my current XSLT program.
Any suggestions?  /Roger

-------------------------------------------------------
       Revised BookStore.xsl
-------------------------------------------------------
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:bk="http://www.books.org"
               input-type-annotations="strip"
               exclude-result-prefixes="bk"
               version="2.0">

    <xsl:output method="xml"/>

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

    <xsl:template match="/">
        <BookISBNs>
            <xsl:for-each select="/bk:BookStore/bk:Book">
                <xsl:if test="string(bk:ISBN) instance of bk:ISBN-type">
                    <ISBN><xsl:value-of select="bk:ISBN"/></ISBN>
                </xsl:if>
            </xsl:for-each>
        </BookISBNs>
    </xsl:template>

</xsl:transform>


-----Original Message-----
From: G. Ken Holman [mailto:g.ken.holman@xxxxxxxxx] On Behalf Of G. Ken
Holman
Sent: Monday, July 15, 2013 3:52 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
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?

At 2013-07-15 19:41 +0000, Costello, Roger L. wrote:
> >    test="string(bk:ISBN) instance of bk:ISBN-type">
>
>Thanks Ken, I see what you're saying.
>
>I gave that a try (I replaced data with string). Unfortunately, I
>get the same error message.

Are you getting that error message at the execution of the test
(where you brought our focus in your post to the list), or is it
associated with the loading of the source document?  If the latter,
you have to turn off schema validation on the loading of the
document, otherwise, of course it won't be valid.  You haven't
protected the validation from happening selectively.

You can use input-type-annotations="strip" so that your input tree
has no type information (and thus won't be constrained by the schema).

I hope this is what you need.

. . . . . . . . Ken


--
Public XSLT, XSL-FO, and UBL classes in the Netherlands     Oct 2013 |
Public XSLT, XSL-FO, UBL and code list classes in Australia Oct 2013 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |

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.