XSL - correct syntax help (solved)

  • Zwirko
  • Guru
  • Guru
  • User avatar
  • Posts: 1417
  • Loc: 55° N, 3° W

Post 3+ Months Ago

I currently use this piece of XSLT to transform an XML file.

Code: [ Select ]
 
<img>
  <xsl:attribute name="src">
  <xsl:value-of select="concat(country/@id,'.png')"/>
  </xsl:attribute>
</img>
 
  1.  
  2. <img>
  3.   <xsl:attribute name="src">
  4.   <xsl:value-of select="concat(country/@id,'.png')"/>
  5.   </xsl:attribute>
  6. </img>
  7.  


The XML looks like this:

Code: [ Select ]
<team>
<country id="cro"></country>
<team_name>NK Buducnost Re&#353;etari</team_name>
<league>Prva HNL</league>
etc
etc
etc
</team>
  1. <team>
  2. <country id="cro"></country>
  3. <team_name>NK Buducnost Re&#353;etari</team_name>
  4. <league>Prva HNL</league>
  5. etc
  6. etc
  7. etc
  8. </team>


The country id is used to print out a flag image in the table. So, in the above example, the XSLT would add the image "cro.png" to the rendered XML. Hope that makes sense.

My problem is that I can only get this to work by having all the flag images in the same directory as the XML files (makes a mess). I'd like to put all my flag images in their own directory, but I've no idea how to modify the XSLT to look in that directory rather than merely in the current one.

So, at the moment I've got the XSLT making links like this: "cro.png"; I'd like them to look like this: "flags/cro.png"

Any ideas? I'm sure it's a simlple thing..
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Zwirko
  • Guru
  • Guru
  • User avatar
  • Posts: 1417
  • Loc: 55° N, 3° W

Post 3+ Months Ago

Got it.

After nearly two years of on-off puzzling over this problem, I finally figure it out.


Code: [ Select ]
<img>
<xsl:attribute name="src">
<xsl:value-of select="concat('../flags/',country/@id,'.png')"/>
</xsl:attribute>
</img>
  1. <img>
  2. <xsl:attribute name="src">
  3. <xsl:value-of select="concat('../flags/',country/@id,'.png')"/>
  4. </xsl:attribute>
  5. </img>



(I knew it was something simple).

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 69 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.