Re: href and template

Subject: Re: href and template
From: "Dan Machak" <machak@xxxxxxxxxxxx>
Date: Thu, 5 Aug 1999 10:26:13 -0700
On May 5,  4:40pm, f.merle wrote:
> I asked to go to
> template VdkVgwKey. Then,to put in the link "titre". but I obtain in
> link VdkVgwKey !!!!!

If I understand correctly, you want as output:
<A href="phlo.xml">GLOSSAIRE</A>

(see example xsl at end of message)
When your VdkVgwKey template is instantiated, the context node-set is contains
just <CHAMP NAME="VdkVgwKey">phlo.xml</CHAMP>, so it doesn't find anything
matching "CHAMP[(@NAME='Titre')]" among its children. Also, in the value-of
element, you used a match attribute. I think select is supposed to be used in
this case (at least in the version of XT that I'm using: XT19990725)

>
> - In a second time, if I want to reuse the template "Titre" for a
> special prtinting on a screen, how do I do?
>
> - when I try to put text to get a printing of "titre" alone, the "titre"
> is printed like the link before with the same result. How is it possible
> because I don't ask it from VdkVwgKey??
> thanks for you help

You need to either 'apply-templates' again, selecting just the Titre elements.
You could also use xsl:for-each.

In the future, it may be easier to understand what you want if you also provide
and example of how the transformed document should look.

>
> Sorry for my poor english, I am french :-)

No need to apologize, your english is better than my french. ;-)

>
> res.xml:
> <DOCRESULT>
> <CHAMP NAME="SCORE">0,77</CHAMP>
> <CHAMP NAME="VdkVgwKey">phlo.xml</CHAMP>
> <CHAMP NAME="Nom">FRED</CHAMP>
> <CHAMP NAME="Prenom"></CHAMP>
> <CHAMP NAME="Titre">GLOSSAIRE</CHAMP>
> </DOCRESULT>
>

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

<xsl:template match="DOCRESULT">
  <P><normal>
    <xsl:apply-templates select="CHAMP[@NAME='VdkVgwKey']"/>
    <xsl:apply-templates select="CHAMP[@NAME='Titre']"/>
  </normal></P>
</xsl:template>

<xsl:template match="CHAMP[(@NAME='VdkVgwKey')]">
  <A>
    <xsl:attribute name="href"><xsl:value-of select="text()"/></xsl:attribute>
	<xsl:value-of select="../CHAMP[(@NAME='Titre')]"/>
  </A>
</xsl:template>

<xsl:template match="CHAMP[(@NAME='Titre')]">
  <normal>
    <xsl:value-of select="text()"/>
  </normal>
</xsl:template>

</xsl:stylesheet>

OUTPUT from XT19990725:

<P>
<normal>
<A href="phlo.xml">GLOSSAIRE</A>
<normal>GLOSSAIRE</normal>
</normal>
</P>

>-- End of excerpt from f.merle



-- 
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<> Dan Machak                    <>  machak@xxxxxxxxxxxx  <>
<> MS T27A-1                     <>  650-604-2388 (VOICE) <>
<> NASA Ames Research Center     <>  650-604-3957 (FAX)   <>
<> Moffett Field, CA 94035-1000  <>                       <>
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • href and template
    • f.merle - Wed, 05 May 1999 16:40:44 +0100
      • Message not available
        • Dan Machak - Thu, 5 Aug 1999 10:26:13 -0700 <=