Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Use of data() function

From: "Andrew Welch" <andrew.j.welch@--------->
To:
Date: 3/5/2008 10:16:00 AM
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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent