Re: [xsl] Accessing the XML file name from an XSL Transform

Subject: Re: [xsl] Accessing the XML file name from an XSL Transform
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 15 Nov 2010 18:51:12 +0000
Ok. I'm missing a little bit more, I'm afraid. I think this is to do with variable scope, but I'm stood ready to be corrected.

Spot on.
I''ve got this:-

8<----------------
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" indent="yes" name="TextFormat" omit-xml-declaration="yes"/>
<xsl:param name="OutputPath" />
<xsl:variable name="FileFullPathName" select="document-uri(/)"/>
<xsl:variable name="FileName" />

<xsl:template match="/hello-world">
<xsl:analyze-string select="$FileFullPathName"
regex="[^/]+$">
<xsl:matching-substring>
<xsl:variable name="FileName" select="." />
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>


You want something like:

<xsl:variable name="FileName">
<xsl:analyze-string ....
</xsl:analyze-string>
</xsl:variable>

Or more simply, perhaps the logic is the same as

<xsl:variable name="FileName" select="tokenize($FileFullPathName), '/')[last()]"/>

Michael Kay
Saxonica

Current Thread