 |
| 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
|
|
|
|

June 8th, 2006, 03:11 PM
|
|
Registered User
|
|
Join Date: Jun 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Parse a field
I have a field which could include one or 3 times <last, first> name appended together (eg for three 'last, firstlast, first Mlast, first').
How can I separate these three occurance properly with a '|' in below xslt code.
The name field includes 0 to 3 NickNickNick, I need to parse it to ||| or Nick|Nick|Nick| or Nick|| or Nick|Nick||
<xsl:choose>
<xsl:when test="name[@type='other']">
<xsl:apply-templates select="name[@type='other']"/>
<xsl:text>|</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>|</xsl:text>
<xsl:text>|</xsl:text>
<xsl:text>|</xsl:text>
</xsl:otherwise>
<xsl:text>#10;</xsl:text>
</xsl:choose>
Thanks for all your help,
Victoria
|
|

June 8th, 2006, 05:09 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Sorry, I don't understand the format of your input. This description is about as obscure as you can get:
(eg for three 'last, firstlast, first Mlast, first').
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

June 8th, 2006, 06:09 PM
|
|
Registered User
|
|
Join Date: Jun 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Below is what I see in my output, however the data could be in the format after my code change:
||
(last, first)
(last, firstlast, first)
(last, firstlast, firstlast, first)
Which I need to parse the data to
||||
|last, first|||
|last, first|last, first||
|last, first|last, first|last, first|
I hope this is clear....
- Victoria
|
|

June 9th, 2006, 02:00 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Please explain what your input looks like.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

June 12th, 2006, 01:36 PM
|
|
Registered User
|
|
Join Date: Jun 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is how my output looks like:
||
(last, first)
(last, firstlast, first)
(last, firstlast, firstlast, first)
And, below is how it should look after the parse:
||||
|last, first|||
|last, first|last, first||
|last, first|last, first|last, first|
Thx,
Victoria
|
|

June 12th, 2006, 01:51 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
I asked you what the input looked like.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
 |