[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|