![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Beginner's questions Beginner's questionsTo: 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:  <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?
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
