[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: remove relative path
On 5/16/06, Gav.... <brightoncomputers@xxxxxxxxxxxxxxxxxxx> wrote:
Hi All,path. Obviously they can be nested values too such as ../../../prepend A predetermined path onto it.)
XSLT 2.0 has better ways, and probably so does XSLT 1.0. But right off the top of my head even without thinking, I can come up with a recursive way: Something like: <xsl:template match="path"> <filename> <xsl:call-template name="getFilename"> <xsl:with-param name="path_string" select="." /> </xsl:call-template> </filename> </xsl:template> <xsl:template name="getFilename"> <xsl:param name="path_string" /> <xsl:choose> <xsl:when test="starts-with($path_string,'../')"> <xsl:call-template name="getFilename"> <xsl:with-param name="path_string" select="substring-after($path_string,'../')" /> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($path_string,'/../')"> <xsl:call-template name="getFilename"> <xsl:with-param name="path_string" select="substring-after($path_string,'/../')" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$path_string"/> </xsl:otherwise> </xsl:choose> </xsl:template> This assuming the path is an element in path, but it should be straightforward enough to figure out. There's probably lots of other ways to do this. Jon Gorman
|
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
|