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 June 14th, 2006, 02:22 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to pull duplicate fields from an item and etc

ok, so briefly put, i am XMLing my music list, as just sort of a fun/intro to xml thing

but am running across a few issues

say that i have a split record.. the way i have that defined now in my XML is simply an elemnt with two <ARTIST> fields. how can i code my XSLT to pull them, seperated like ARTIST1/ARTIST2/ETC if more than one exist...

and i have a similar issue with various other fiends in my object.. but if i can figure it out once i should be able to figure it out for them all

thanks

 
Old June 14th, 2006, 03:08 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you want an answer, the golden rules are:

1. Simplify your problem to the essentials
2. Describe it clearly, by means of input and required output
3. Explain how far you've got and where you hit difficulties

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 14th, 2006, 08:24 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

okkkkk

1. does xml straight up allow two duplicate fields with the same name within one element

an example would be this
    <EP>
        <ARTIST>d'amore</ARTIST>
        <ARTIST>towers</ARTIST>
        <COLOR>pink</COLOR>
        <LABEL>delian league</LABEL>
        <YEAR>2005</YEAR>
    </EP>


and then if it does

2. how can i write XSL code which retrieves all fields with a given name from the element in succession.. in the above case, all of the <ARTIST> fields, seperating them with some kind of character, say "/" between each
 
Old June 14th, 2006, 09:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There's no such thing as a "field" in XML. If you mean elements the answer is yes (duplicates are allowed). If you mean attributes then the answer is no.

<xsl:for-each select="xxx">
  <xsl:value-of select="."/>
  <xsl:if test="position()!=last()">/</xsl:if>
</xsl:for-each>

Or in XSLT 2.0, use the string-join function.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 14th, 2006, 10:02 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yeah i was afraid i was using wrong terminology

xml is a new beast to me

thanks for the help






Similar Threads
Thread Thread Starter Forum Replies Last Post
Pull or Push? sureshvb Crystal Reports 0 August 23rd, 2004 01:13 AM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM
Pull info from 2 tables stacy Classic ASP Databases 6 March 19th, 2004 10:46 AM
Removing Duplicate Fields antonides Access 2 December 1st, 2003 07:37 PM
Find Out First Item of each item Group Jane SQL Language 1 November 22nd, 2003 12:42 PM





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