[xsl] xsl:attribute problem

Subject: [xsl] xsl:attribute problem
From: Jens Laufer <jens@xxxxxxxxxxxxxx>
Date: Mon, 2 Dec 2002 11:57:53 +0100
Hi all,
I need to solve this problem:
I want to create this output from a XML-source and a XSL-stylesheet:


<---snippet---!>
<a href="mailto: <?php echo $email?>"><?php echo $email?></a>
<---snippet---!>


I am using this XSL-stylesheet:
<---snippet---!>
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">


  <xsl:output method="html" indent="yes"/>


  <xsl:template match="/document">
     <a>
      <xsl:attribute name="href">mailto:<xsl:apply-templates 
select="email"/></xsl:attribute>
      <xsl:apply-templates select="email"/>
     </a>
  </xsl:template>


 <xsl:template match='email'>
  <xsl:apply-templates/>
 </xsl:template>


 <xsl:template match='*|@*'>
    <xsl:copy>
        <xsl:apply-templates select='node()|@*'/>
    </xsl:copy>
 </xsl:template>


</xsl:stylesheet>
<---snippet---!>


I tried this XML to get that output:
======================================================================
XML:


<?xml version="1.0" encoding="iso-8859-1"?>
<document>
  <email><xsl:pi value="php">echo $email</xsl:pi></email>
</document>



I get this error:
java.io.IOException: /home/jens/test/test.xsl:7: element `xsl:pi' is not 
allowed inside attribute `href'.


================================================================
XML:


<?xml version="1.0" encoding="iso-8859-1"?>
<document>
  <email><script language="php">echo $email</script></email>
</document>


I get this error:
java.io.IOException: /home/jens/test/test.xsl:7: element `script' is not 
allowed inside attribute `href'.


=================================================================
XML:


<?xml version="1.0" encoding="iso-8859-1"?>
<document>
  <email><?php echo $email ?></email>
</document>


I get this output:


<a href="mailto:";></a>


=================================================================
XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<document>
  <email>&lt;?php echo $email ?&lt;</email>


I get this output:


<a href="mailto:<?php echo $email ?&lt;">&lt;?php echo $email ?&lt;</a>
==================================================================
I don't really know how to solve that and I am struggling around with it since  
a while now...


Actually I don't want to change the stylesheet too much, because with the 
current stylesheet it should be possible to swap quickly technologies:
You just change e.g. <?php echo $test?> into <%=test%> and you can use jsp...
So there should be no "technologiy" infromation in the stylesheet.


I think especially the attributes are making a lot of problems...
Any ideas?
Thanks in advance!
Jens





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


Current Thread