Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2003, 12:02 PM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default transform element contents

i'm stuck at my xslt-stylesheet, trying to get and partly change the contents of an element - it looks like this:

<ATTRIBUTE>ITEM: "Winword"param:"C:\\Documents and Settings\\clemens\\Desktop\\Clemens XML"</ATTRIBUTE>

all i want is to draw the part after C: and before the final ", and change the dobbelslashes to single ones.
is there any combined functions that could make that possible ?
 
Old September 16th, 2003, 12:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

You can use saxon:tokenize extension function; if you're using another XSLT processor, you can write simple template "replace" which replaces occurences of string1 with string2 in some string. I your processor isn't Saxon and you have problems with writing that template, let me know.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
exclude-result-prefixes="saxon"
extension-element-prefixes="saxon">
    <xsl:template match="ATTRIBUTE">
        <xsl:copy>
            <xsl:for-each select="saxon:tokenize(concat(' ', substring-before(substring-after(., 'C:'), '&quot;'), ' '), '\\')">
                <xsl:value-of select="normalize-space(.)"/>
                <xsl:if test="position() != last()">
                    <xsl:text>\</xsl:text>
                </xsl:if>
            </xsl:for-each>    
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
Regards,
Armen





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
Transform multilined element value to one line ypomonh XSLT 2 April 27th, 2007 08:32 AM
translate element name to element name lexzeus XSLT 3 September 4th, 2006 09:04 AM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM
transform element contents advisor XSLT 0 September 15th, 2003 12:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.