Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Beginner's questions

From: Howard Brazee <howard@------.--->
To: NULL
Date: 8/1/2007 2:44:00 PM

I'm writing an .XSL for the iTunes XML file.


Part 1:
My first problem is that C:\Documents and Settings\brazee\My
Documents\My Music\iTunes\iTunes Music Library.xml doesn't have a
style sheet in it, so I copy it and add the following line in it:
<?xml-stylesheet href="myiTunes.xsl" type="text/xsl"?>

Is there a trick to avoid this?

Part 2:

Then the XML is oddly designed.  The following is one record:

<key>1056</key>
<dict>
<key>Track ID</key><integer>1056</integer>
<key>Name</key><string>Gorecki - Symphony 3., op36. 1. Lento.
Sostenuto tranquillo ma catabile</string>
<key>Artist</key><string>Orchestre Philharmonique de Varsovie,
Kazimierez Kord</string>
<key>Composer</key><string>Henryk Mikolaj Gorecki</string>
...

When a field is empty, it is is missing.

So I tried this:
 <xsl:template match='dict'>
   <xsl:for-each select='key'>
       <xsl:if test='. = "Name"'>
   	<br/>Name: &#160;<xsl:value-of select='../string[position() =
1]'/>
      </xsl:for-each><br/>
 </xsl:template>

This works because "Name" always exists in position 1.

But if I want rating, I need to find out what position it is at.   It
may be 13, or it may be 12 or it may be something else, depending on
how many fields are defined for that record.

My desired output here is:

Sequence    Name    		Rating
    1           My Song                3
    2           My Other Song    (blank)

Where it didn't find the field "Rating" in this record.

How should I create the XSL to do this?



			


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent