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

Re: Use of data() function

Subject: Re: Use of data() function
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Wed, 5 Mar 2008 10:15:32 +0000
Re:  Use of data() function
On 04/03/2008, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>  > I don't think most doc-heads would accept as valid the idea
>  > that a mixed content element (especially if the element has
>  > the mixed content in it) is of type string.
>  >
>
> of course, and it isn't of type string. But if you atomize it you get an
>  untypedAtomic value which can be used anywhere you might use a string.

Here's a standalone transform to demonstrate the issue:

<xsl:stylesheet
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

    <xsl:import-schema>
        <xs:schema>
            <xs:element name="person" type="person"/>

            <xs:complexType name="person">
                <xs:sequence>
                    <xs:element name="surname"/>
                    <xs:element name="name"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </xsl:import-schema>

    <xsl:variable name="input">
        <person xsl:type="person">
            <surname>bloggs</surname>
            <name>joe</name>
        </person>
    </xsl:variable>

    <xsl:template match="/" name="main">
        <xsl:value-of select="data($input/person)"/>
    </xsl:template>

</xsl:stylesheet>

The input is validated and the <person> element is typed as "person"
according to the embedded schema.

Calling data($input/person) results in the error:

"Cannot get the typed value of an element with element-only content"

If the schema is modified to give person mixed content:

<xs:complexType name="person" mixed="true">

and then you re-run the transform after making just that one small
change, you get this:

bloggsjoe

...which is a bit odd to me at the moment.  It seems a bit of an
artificial restriction.


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.