RE: [xsl] Value-of varible question

Subject: RE: [xsl] Value-of varible question
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Fri, 16 Apr 2004 14:52:59 -0600
Yep, I can definitely tell you your solution wont work and the reason
why it wont work but dont think of it as being wrong, but instead only
one solution away from being right ;)  Hah!  It's been a long day of
politically correct behavior (not in the list but in real life) and I
figured why interrupt the flow :) Anybody else ready for a BEER?!!!

Anyway, there are three approaches to this but the first one is way to
easy to justify the extra code in the second and the third would be a
total overkill to a very simple problem.  So lets start with one and see
what happens from there...

By using two templates, the second matching the Title element, we can
simply use XPath to select all Title elements that match our string
criteria and make copys of them once we arrive in the second template.
So, in code (which always seems to make more sense than my words for
some reason :)...

Btw, youll have to adjust your XPath accordingly to reach the correct
element within your structure.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

<xsl:variable name="local" select="'en-EN'"/>

<xsl:template match="/">
  <xsl:apply-templates select="Title[@lang = $local]"/>
</xsl:template>

<xsl:template match="Title">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>

Best of luck!

<M:D/>

-----Original Message-----
From: John Hamman [mailto:John@xxxxxxxxxxxxxxxxx] 
Sent: Friday, April 16, 2004 2:27 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Value-of varible question

Awsome!!! Thanks
One more question. Im getting the results like this.

<Title lang="en-US">Williamsburg Web Design</Title>
<Title lang="en-US">Williamsburg Web Design</Title>

>From an xml file like this.
	<Title lang="en-US">Williamsburg Web Design</Title>
	<Title lang="es-ES">Diseqo Del Web De Williamsburg</Title>

It seams that its is using the value of one for both. I just want to
return
the one that lang matches. Any idea on what im doing wrong?




-----Original Message-----
From: Andreas L. Delmelle [mailto:a_l.delmelle@xxxxxxxxxx] 
Sent: Friday, April 16, 2004 4:26 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Value-of varible question

> -----Original Message-----
> From: John Hamman [mailto:John@xxxxxxxxxxxxxxxxx]
> 
> For some reason this won't work 
> <xsl:param name="local" select="en-EN"/>
> <xsl:template match="Title">
> 		<Title>
> 			<xsl:copy-of
> select="/iThink.ePulp/Page/Content/Meta/Title[@lang=$local]"/>
> 		</Title>
> 	</xsl:template>
<snip />
 
> Does anyone know why and is there a way I can get around it?

Yes. Use :

<xsl:param name="local" select="'en-EN'" />

(mind the quotes..)


Cheers,

Andreas

Current Thread