A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: I need a litle help fixing my template

Hybrid View

  1. #1
    Junior Member
    Join Date
    Jul 2000
    Posts
    27

    I need a litle help fixing my template

    Hello and thank you, I'm with a problem trying to create .txt file from a xml file, the xml file have that format (it's a music catalog):
    PHP Code:
    <catalog>
      <
    artist ID="">
      <
    name></name>
      <
    country></country>
      <
    style></style>
      <
    cds>
       <
    cd>
        <
    title></title>
        <
    year></year>
        <
    musics>
         <
    name length=""></name>
            </
    musics>
       </
    cd>
     </
    artist>
    </
    catalog
    Example:
    PHP Code:
    <catalog>
      <
    artist ID="12">
      <
    name>Dave Matthews Band</name>
      <
    country>U.S.A</country>
      <
    style>Rock Blues</style>
      <
    cds>
       <
    cd>
        <
    title>Everyday</title>
        <
    year>2001</year>
        <
    musics>
         <
    name length="3:36">I Did It</name>
         <
    name length="3:32">When The World Ends</name>
         <
    name length="4:03">The Space Between</name>
         <
    name length="4:41">Dreams Of Our Fathers</name>
         <
    name length="4:41">So Right</name>
         <
    name length="4:03">If I Had It All</name>
         <
    name length="4:33">What You Are</name>
         <
    name length="3:56">Angel</name>
         <
    name length="4:14">Fool To Think</name>
         <
    name length="4:25">Sleep To Dream Her</name>
         <
    name length="4:24">Mother Father</name>
         <
    name length="4:43">Everyday</name>
        </
    musics>
          </
    cd>
         
         <
    cd>
          <!-- 
    another cd info -->
         </
    cd>
      </
    cds>
     </
    artist>
      <!-- 
    more artists -->
    </
    catalog
    I'm trying to create a .txt file that include all artists in catalog in that format:

    Artist:
    Country:
    Style:
    Cds:
    Title:
    Year:
    Musics:


    Here is my template:
    PHP Code:
    <? xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" encoding="windows-1252"/>
     <xsl:template match="/">

      <xsl:for-each select="/catalog/artist">
       Artist: <xsl:value-of select="name"/>
       Country: <xsl:value-of select="country"/>
       Style: <xsl:value-of select="Style"/>
      
      Cds:
       <xsl:for-each select="cds/cd">
       Title:<xsl:value-of select="title"/> 
       Year:<xsl:value-of select="year"/>
       Musics:<xsl:for-each select="musics/name"><xsl:value-of    select="."/></xsl:for-each></xsl:for-each></cds>
       </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>

    It show everything, the Problem is that it show the musics just in one line like:

    Musics:I Did ItWhen The World EndsThe Space BetweenDreams Of Our FathersSo RightIf I Had It AllWhat You AreAngel

    There is a way to it show the music name like it:
    Musics:
    I Did It
    When The World Ends
    The Space Between
    Dreams Of Our Fathers
    So Right
    If I Had It All
    What You Are
    Angel

    And if possible put the length of music in the right side of the music name? since it is a attribute? Like it:

    Musics:
    I Did It 3:36


    Damn look like i have write a book.

    Thank You Alot.

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    A couple of options. The first is some parsers have a processing command to keep whitepace. XSL parsers generally just ignore whitespace and output the data.

    The other option is to embed the appriorate end of line markers for your operating system. This can be done by placing the hex code in your xsl document.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center