Subject: Re: [xsl] Use of data() function From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Wed, 5 Mar 2008 10:15:32 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Use of data() function, Michael Kay | Thread | RE: [xsl] Use of data() function, Michael Kay |
Re: [xsl] Processing based on numbe, Dimitre Novatchev | Date | RE: [xsl] Use of data() function, Michael Kay |
Month |