Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6714475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:30:01+00:00 2026-05-26T08:30:01+00:00

I have an XML Schema that contains the following type element: <xs:simpleType name=value> <xs:union

  • 0

I have an XML Schema that contains the following type element:

<xs:simpleType name="value">
  <xs:union memberTypes="xs:boolean xs:int xs:double xs:string"/>
</xs:simpleType>

A sample XML fragment would be:

<value>42</value>

In an XSLT transform, how do I determine which type the value has, i.e., is it a boolean, an integer, a double, or a string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:30:02+00:00Added an answer on May 26, 2026 at 8:30 am

    In an XSLT transform, how do I determine which type the value has,
    i.e., is it a boolean, an integer, a double, or a string?

    If there isn’t a schema associated with the XML document, the answer is that the type is always xs:string and the question isn’t too meaningful.

    However, the correct question is: With which of those types is this compatible (castable as) ?

    This transformation shows how this can be found out. It also illustrates the elegance and power of <xsl:next-match>:

    <xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="text()[. castable as xs:integer]">
         <xsl:sequence select="., ' is castable as xs:integer. '"/>
         <xsl:next-match/>
     </xsl:template>
    
     <xsl:template match="text()[. castable as xs:boolean]">
         <xsl:sequence select="., ' is castable as xs:boolean. '"/>
         <xsl:next-match/>
     </xsl:template>
    
     <xsl:template match="text()[. castable as xs:string]">
         <xsl:sequence select="., ' is castable as xs:string. '"/>
         <xsl:next-match/>
     </xsl:template>
    
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <value>42</value>
    

    the wanted, correct result is produced:

    42 is castable as xs:string. 42 is castable as xs:integer. 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML schema that contains the following type : <xs:simpleType name=valuelist> <xs:list
I have an XML schema that includes multiple addresses: <xs:element name=personal_address maxOccurs=1> <!-- address
I have a schema fragment that looks like <xs:element name=dataValue> <xs:complexType> <xs:sequence> <xs:element name=value
I have an existing XML schema that contains a type that I would like
I have a web service that returns following type: <xsd:complexType name=TaggerResponse> <xsd:sequence> <xsd:element name=msg
I have the following complex type in my XML schema: <xs:complexType name=Widget mixed=true> <xs:sequence>
Assuming I have a schema that describes a root element class Root that contains
I have an XSD file that contains the following... <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema elementFormDefault=qualified id=OTA2003A targetNamespace=http://www.opentravel.org/OTA/2003/05
I have to validate XML file that contains embedded XML, with XML Schema. Correctness
I have a XML schema that I will need to create Java classes for.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.