[Home] [By Thread] [By Date] [Recent Entries]
At 2009-10-07 15:04 -0400, mlcook@xxxxxxxxxx wrote:
Is there a way using XSLT 2.0 to determine whether an element has no attributes present in an XML document? That isn't quite what you are asking, though. Say, given the type, with default values: Right ... which means to the stylesheet it reads, when validation is turned on: <time day="0" hour="0" minute="0" second="0"/> which is indistinguishable from an authored: <time day="0" hour="0" minute="0"/> <time day="0" hour="0" second="0"/> ... any combination of specified attributes of "0" and an element with explicit attributes, for example, <time hour="5" minute="27" /> I have an example below working with XSLT 1 (and so XSLT 2). This works whether or not you have supplied the schema and turned on validation. I hope this helps. . . . . . . . . . . . Ken t:\ftemp>type mlcook.xml <times> <time day="0" hour="0" minute="0" second="0">a</time> <time hour="5" minute="27">b</time> <time day="0">c</time> <time>d</time> </times> t:\ftemp>xslt mlcook.xml mlcook.xsl "Empty": a Not "empty": b "Empty": c "Empty": d t:\ftemp>type mlcook.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:output method="text"/> <xsl:template match="time"> "Empty": <xsl:value-of select="."/> </xsl:template> <xsl:template match="time[@*!='0']"> Not "empty": <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet> t:\ftemp>
|

Cart



