Subject: [xsl] Context in nested loop From: "Joseph L. Casale jcasale@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 28 Jul 2017 14:11:16 -0000 |
I am unclear with the correct syntax for the corresponding context of the $name and $attr variables in the following repro. For $name, mailto:../@name is what I want, but I know that is incorrect and for $attr, "." gets the value and not the name. This is similar to a question I had a few days ago, yet in this case I am still unable to figure it out. Does a way exist to avoid the variables? Thanks, jlc <root> <nodeA> <nodeB name="MyName" attrB="2" attrC="3" /> </nodeA> </root> <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output encoding="UTF-8" indent="yes" method="xml" /> <xsl:strip-space elements="*" /> <xsl:variable name="document" select="document('file.xml')" /> <xsl:template match="/"> <xsl:for-each select="/root/nodeA/nodeB"> <xsl:variable name="name" select="@name"/> <xsl:for-each select="@*"> <xsl:variable name="attr" select="local-name()"/> <xsl:if test="name()!='name'"> <xsl:message> <xsl:value-of select="$document/foo/bar[@name=$name]/@*[local-name()=$attr]" /> </xsl:message> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[no subject], Unknown | Thread | Re: [xsl] Context in nested loop, Martin Honnen martin |
Re: [xsl] Mode in XSLT 3.0, Toshihiko Makita tma | Date | Re: [xsl] Context in nested loop, Martin Honnen martin |
Month |