Jump to content

thursday

Members
  • Posts

    2
  • Joined

  • Last visited

thursday's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Ok, I have come up with a solution, however I get an error that I doubt I should. Here is the XML file again: <?xml-stylesheet type="text/xsl" href="namepath_xsl"?><element name="A"> <element name="B"> </element> <element name="C"> <element name="D"> </element> </element></element> The proposed XSLT solution looks like this: <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> <xsl:template match="/"> <html> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="element"> <p> Element: "<xsl:value-of select="@name"/>"<br/> Path: "<xsl:call-template name="pathname"/>" </p> <xsl:apply-templates/> </xsl:template> <xsl:template name="pathname"> <xsl:param name="source" select="."/> <xsl:if test="$source != fn:root()"> <xsl:call-template name="pathname"> <xsl:with-param name="source" select="$source/../."/> </xsl:call-template> </xsl:if> <xsl:text>/</xsl:text><xsl:value-of select="$source/@name"/> </xsl:template></xsl:stylesheet> However, this returns in error in IE6. This error is shown below. I have tried both "http://www.w3.org/2005/xpath-functions" as well as "http://www.w3.org/2005/02/xpath-functions" and I still get this error. Any help would be greatly appreciated!! Thanks!
  2. I was wondering if it would be possible to change the current XPath, a single time. For example, <xsl:for-each select="___"> changes the XPath such that each item is effectively treated as the root. I was wondering if there was a way to do this once.My goal was to be able to print the current "path" a node is in. Say the above function is called like "with"... something like the following: <xsl:template name="qname"> <xsl:with select="../"> <xsl:call-template name="qname"/> </xsl:with> <xsl:text>/</xsl:text><xsl:value-of select="@name"></xsl:template> Which ideally, when called, in the below xml file... <element name="a"> <element name="b"> </element> <element name="c"> <element name="d"> </element> </element></element> When called from the element who's name is "d", would output:a/c/dAnyways, does anybody have any idea how to do either of these problems??
×
×
  • Create New...