p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XSLT
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 24th, 2007, 03:40 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default seperate string by ^

<xsl:variable name="HISTORY" select="./@history" />

The result is a String like

abc^defg^ttt^bbb^ggg

I am tring to get like

abc
defg
ttt
bbb
ggg

-------------------------------------------------------------------------------------


<xsl:variable name="HISTORY_BEFORE" select="substring-before($HISTORY,'^')" />
<xsl:variable name="HISTORY_AFTER" select="substring-after($HISTORY,'^')" />
<xsl:choose>
    <xsl:when test="string-length($HISTORY_BEFORE) > 0" >
        <xsl:value-of select="substring-before($HISTORY,'^')" />
        <br />
        <xsl:if test="string-length($HISTORY_AFTER) > 0">
            <xsl:value-of select="substring-before($HISTORY_AFTER,'^')" /><br />
            <xsl:value-of select="substring-after($HISTORY_AFTER,'^')" />
        </xsl:if>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="./@history" />
    </xsl:otherwise>
</xsl:choose>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 24th, 2007, 05:32 PM
Friend of Wrox
Points: 1,343, Level: 14
Points: 1,343, Level: 14 Points: 1,343, Level: 14 Points: 1,343, Level: 14
Activity: 15%
Activity: 15% Activity: 15% Activity: 15%
 
Join Date: Jul 2006
Location: , , .
Posts: 366
Thanks: 8
Thanked 0 Times in 0 Posts
Send a message via Yahoo to bonekrusher
Default

Hi,

Please post some of the XML and someone can help.

Bones


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old July 24th, 2007, 06:55 PM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

I suspect an error in the code you haven't shown us - for example, the context might be wrong. Please show a complete (but small) XML source document and stylesheet, this is much easier to debug than a fragment.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 24th, 2007, 09:29 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<test>
<testdata history="aaa^bbb^ccc^ddd"></testdata>
</test>

-----------------------------------
 <xsl:variable name="HISTORY" select="../test/testdata/@history" />

<xsl:variable name="HISTORY_BEFORE" select="substring-before($HISTORY,'^')" />
<xsl:variable name="HISTORY_AFTER" select="substring-after($HISTORY,'^')" />
<xsl:choose>
    <xsl:when test="string-length($HISTORY_BEFORE) > 0" >
        <xsl:value-of select="substring-before($HISTORY,'^')" />
        <br />
        <xsl:if test="string-length($HISTORY_AFTER) > 0">
            <xsl:value-of select="substring-before($HISTORY_AFTER,'^')" /><br />
            <xsl:value-of select="substring-after($HISTORY_AFTER,'^')" />
        </xsl:if>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="./@history" />
    </xsl:otherwise>
</xsl:choose>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old July 24th, 2007, 09:35 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<document>
    <testxml>
        <test1>
        <test1a>
                          <test>
                                 <testdata history="aaa^bbb^ccc^ddd"></testdata>
                          </test>
                         </test1a>
                </test1>
            </testxml>
</document>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old July 24th, 2007, 09:51 PM
Friend of Wrox
Points: 1,343, Level: 14
Points: 1,343, Level: 14 Points: 1,343, Level: 14 Points: 1,343, Level: 14
Activity: 15%
Activity: 15% Activity: 15% Activity: 15%
 
Join Date: Jul 2006
Location: , , .
Posts: 366
Thanks: 8
Thanked 0 Times in 0 Posts
Send a message via Yahoo to bonekrusher
Default

Hi, You should use the tokenize function

tokenize(string,pattern)

something like

for $w in tokenize($History,'^') return $w


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old July 24th, 2007, 11:08 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using version 1.0

is it working with that version?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old July 25th, 2007, 03:00 AM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

As I said, the problem could well be that the context isn't set up correctly for your code to run. The fact that you haven't demonstrated the context suggests that you haven't understood its importance.

I'm also confused as to why you have shown two different versions of your source document, without any explanation.

As I said before, please provide a complete runnable example that demonstrates the problem, so we can tell you where you went wrong.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CreatBackup:=True but in seperate folder mona_upm84 Excel VBA 0 July 18th, 2008 01:07 AM
Call to subroutine from seperate workbook Coby Excel VBA 2 February 1st, 2008 10:15 PM
Why not seperate OBJ layer susahin80 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 January 19th, 2007 03:51 PM
1 form, contains two seperate controls EricJ General .NET 2 August 10th, 2005 05:48 AM
Seperate Code JsonTerre1 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 November 7th, 2004 04:38 PM



All times are GMT -4. The time now is 03:09 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc