[Home] [By Thread] [By Date] [Recent Entries]
I see that you are dealing with only the names of the grandchildren
of the root. The vollowing has three solutions, one based on the
names (as you have done) and two that are namespace-safe. The latter
two are equivalent, but since the operators "every" and "some" didn't
come to mind for you, I thought I would illustrate both.
The second two work with axes the way you were getting started. But for the first I think you can rephrase your problem to be not that all elements have one parent but that there is only one of every element ... which I think is equivalent given the limited amount of information regarding your objective. I hope this helps. . . . . . . Ken ~/t/ftemp $ cat roger1.xml
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<D1>
<D2/>
<F1/>
</D1>
<D2>
<F2/>
</D2>
</Root>
~/t/ftemp $ cat roger2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<D1>
<D2/>
<F1/>
</D1>
<D2>
<F2/>
<F1/>
</D2>
</Root>
~/t/ftemp $ xslt2 roger1.xml roger.xsl
true
true
true
~/t/ftemp $ xslt2 roger2.xml roger.xsl
false
false
false
~/t/ftemp $ cat roger.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0"><xsl:output method="text"/> <xsl:template match="/">
<xsl:value-of select="
count(/Root/*/*)=count(distinct-values(/Root/*/*/name(.)))"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="
every $elem in /Root/*/* satisfies
not($elem/following::*[not(*)]/node-name(.)=node-name($elem))"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="
not( some $elem in /Root/*/* satisfies
$elem/following::*[not(*)]/node-name(.)=node-name($elem))"/>
<xsl:text>
</xsl:text>
</xsl:template></xsl:stylesheet> ~/t/ftemp $ At 2016-10-16 22:33 +0000, Costello, Roger L. costello@xxxxxxxxx wrote: Hi Folks, -- Check our site for free XML, XSLT, XSL-FO and UBL developer resources | Streaming hands-on XSLT/XPath 2 training @US$45: http://goo.gl/Dd9qBK | Crane Softwrights Ltd. _ _ _ _ _ _ http://www.CraneSoftwrights.com/s/ | G Ken Holman _ _ _ _ _ _ _ _ _ _ mailto:gkholman@xxxxxxxxxxxxxxxxxxxx | Google+ blog _ _ _ _ _ http://plus.google.com/+GKenHolman-Crane/posts | Legal business disclaimers: _ _ http://www.CraneSoftwrights.com/legal |
|

Cart



