On Fri, 13 Apr 2007 06:48:26 -0400, Andrew Welch
<andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:
<xsl:for-each select="//*">
Maybe this should be select="node()" and then apply-templates on it and
match all possible nodes??
best,
-Rob
<xsl:variable name="path" select="concat('/',
string-join(for $x
in ancestor-or-self::*
return concat($x/local-name(), '[',
count(.|$x/preceding-sibling::*[name() = current()/name()]), ']'),
'/'))" as="xs:string"/>
<xsl:for-each select="text()[normalize-space(.) !=
'']">
<check><xsl:value-of
select="concat($path, '/text[', position(),
'] = ''', .,'''')"/></check>
</xsl:for-each>
<xsl:for-each select="@*">
<check><xsl:value-of
select="concat($path, '/@', name(), ' = ''',
., '''')"/></check>
</xsl:for-each>
</xsl:for-each>
</xml>
</checkXML>
</xsl:template>
The result is:
<checkXML>
<xml src="file:/C:/test.xml">
<check>/root[1]/foo[1]/text[1] = 'foo'</check>
<check>/root[1]/foo[1]/@fooatt = 'att'</check>
<check>/root[1]/bar[1]/text[1] = 'bar'</check>
<check>/root[1]/bar[2]/text[1] = 'baz'</check>
</xml>
</checkXML>
The above transform is quick attempt to demonstrate the problem, I'm
sure it can be improved on.
Also, if there are any thoughts about this approach it would be good
to hear them.
cheers
andrew
ps. CheckXML is a work in progress, contact me if you'd like to be
involved.
--~------------------------------------------------------------------
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>
--~--
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--~------------------------------------------------------------------
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>
--~--