On 29/02/2008, Mukul Gandhi <gandhi(_dot_)mukul(_at_)gmail(_dot_)com> 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/
--~------------------------------------------------------------------
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>
--~--