On 04/03/2008, Michael Kay <mike(_at_)saxonica(_dot_)com> 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/
--~------------------------------------------------------------------
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>
--~--