[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Context in nested loop
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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|