xsl-list
[Top] [All Lists]

RE: [xsl] Is there a way to tell if a node is an integer?

2006-04-21 22:06:48
It's real code, allright. The problem you are experiencing is very likely the 
result of your using an XSLT 1.0 transformer. XSLT 2.0 opens the door to 
schema-aware processing. The "xs:" namespace is from XML Schema 
(http://www.w3.org/2001/XMLSchema). XML Schema makes possible the definition of 
elements as being of particular data types. If you were using an XSLT 2.0 
schema-aware processor and you defined your stylesheet as being an XSLT 2.0 
stylesheet, the test would work.

See these links:
http://www.xml.com/pub/a/2000/11/29/schemas/part1.html - A tutorial on XML 
Schema
http://www.w3.org/XML/Schema - Official site of XML Schema at w3.org
http://www.saxonica.com/ - Web site of the first (and arguably the best) XSLT 
2.0 processor, available in schema-aware (paid license) and non-schema-aware 
(no-cost license)
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Allison Bloodworth <abloodworth(_at_)berkeley(_dot_)edu>
Sent:     Fri, 21 Apr 2006 18:31:05 -0700
To:       <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject:  [xsl] Is there a way to tell if a node is an integer?

Hi, 

Is there a way to tell if a node is an integer? I found this message:
http://www.xslt.com/html/xsl-list/2004-10/msg00364.html where it appears to
say you can use a statement like this:

<xsl:if test="data($a) instance of xs:integer">

But this looks kind of strange, and maybe it is pseudo-code because it
breaks my transform. 
                                        <xsl:if
test="./Locations/Location/Address/cbc:Room instance of xs:integer">Room is
an integer</xsl:if>

I want to be able to tell if the cbc:Room node here is an integer:

        <Address>
          <cbc:Postbox languageID="en-us"
languageLocaleID="normalizedString">2105</cbc:Postbox>
          <cbc:Room languageID="en-us"
languageLocaleID="normalizedString">2nd floor</cbc:Room>

          <cbc:StreetName languageID="en-us"
languageLocaleID="normalizedString">Bancroft Way</cbc:StreetName>
          <cbc:CityName languageID="en-us"
languageLocaleID="normalizedString">Berkeley</cbc:CityName>
          <cbc:PostalZone languageID="en-us"
languageLocaleID="normalizedString">94710</cbc:PostalZone>
          <cbc:CountrySubentity languageID="en-us"
languageLocaleID="normalizedString">California</cbc:CountrySubentity>
          <cac:Country>
            <cac:IdentificationCode languageID="en" codeListID="ISO3166-1"
codeListVersionID="0.3"
codeListSchemeURI="urn:oasis:names:specification:ubl:schema:xsd:CountryIdent
ificationCode-1.0" codeListAgencyName="United Nations Economic Commission
for Europe" codeListName="Country"
codeListAgencyID="6">US</cac:IdentificationCode>

          </cac:Country>
        </Address>

Thanks for any help you can give me!

Allison Bloodworth
Principal Administrative Analyst
Technology Program Office
University of California, Berkeley
(415) 377-8243
abloodworth(_at_)berkeley(_dot_)edu




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--