[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Use of data() function (was: Re: [OT])
On 29/02/2008, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote: > What exactly is meant by "effective boolean value" ? Hi Mukul, It's described here: http://www.w3.org/TR/xpath20/#dt-ebv > How should this be exactly interpreted: > <xsl:if test="data(@married)"> I think test="@married" is the same as test="exists(@married)" whereas data(@married) returns the typed value of @married and converts that to true/false. Here's a transform to demonstrate: <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <!-- The schema is written directly within xsl:import-schema --> <xsl:import-schema> <xs:schema> <xs:element name="person" type="person"/> <xs:complexType name="person"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="married" type="xs:boolean"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema> </xsl:import-schema> <xsl:variable name="input"> <person xsl:type="person" married="false">typed singleton</person> <person married="false">singleton</person> </xsl:variable> <xsl:template match="/" name="main"> <xsl:for-each select="$input/person"> <xsl:value-of select="concat('
',.)"/> <xsl:if test="data(@married)"> - married</xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> the output is: typed singleton singleton - married As you can see "married" is output even though it's value if false. I'm not sure this is a great example - if it can be made more real world let me know and I'll add it to http://schema-aware.com -- 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
|