[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with Output special char in HTML attribute

Subject: Re: Problem with Output special char in HTML attribute
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Tue, 07 Dec 2004 09:59:42 -0800
php special char
In addition to what Jeni said (you should able to get the tab count from your source?) you can do it by writing to the output stream.

I have had to do something similar, but with JSP 1.2 (the one with no Expression Language). Basically, I created some elements in the source, like:


<jsp:scriptlet>


String id = someAction.getId();

</jsp:scriptlet>

<jspp:outputElement name="a">
  <jspp:outputAttribute name="href">
    <jspp:concat str_value="next-page.jsp?id="/>
    <jspp:concat var_value="id"/>
  </jspp:outputAttribute>
</jspp:outputElement>

Then the transformation to the JSP (hope you can parse this into PHP) does:


<xsl:template match="jspp:outputElement"> out.print("<xsl:text disable-output-escaping="yes">&lt;</xsl:text>"); out.print("<xsl:value-of select="@local_name"/>"); <xsl:apply-templates select="jspp:outputAttribute" mode="attrOut"/> out.print("<xsl:text disable-output-escaping="yes">&gt;</xsl:text>"); <xsl:apply-templates/> out.print("<xsl:text disable-output-escaping="yes">&lt;</xsl:text>/"); out.print("<xsl:value-of select="@local_name"/>"); out.print("<xsl:text disable-output-escaping="yes">&gt;</xsl:text>"); </xsl:template>

<xsl:template match="jspp:outputAttribute"/>

<xsl:template match="jspp:outputAttribute" mode="attrOut">
  <xsl:choose>
    <xsl:when test="boolean(@name)">
      out.print(" ");
      out.print("<xsl:value-of select="@name"/>");
      out.print("='");
      <xsl:choose>
        <xsl:when test="boolean(@str_value)">
          out.print("<xsl:value-of select="@str_value"/>");
        </xsl:when>
        <xsl:when test="boolean(@var_value)">
          out.print(<xsl:value-of select="@var_value"/>);
        </xsl:when>
        <xsl:otherwise>
          out.print(<xsl:apply-templates/>);
        </xsl:otherwise>
      </xsl:choose>
      out.print("'");
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates mode="attrOut"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<xsl:template match="jspp:concat">


<xsl:if test="not($context='0')">

    <xsl:if test="preceding-sibling::jspp:concat">
      <xsl:text> + </xsl:text>
    </xsl:if>
    <xsl:choose>
      <xsl:when test="boolean(@str_value)">
        <xsl:text>"</xsl:text>
        <xsl:value-of select="@str_value"/>
        <xsl:text>"</xsl:text>
      </xsl:when>
      <xsl:when test="boolean(@var_value)">
        <xsl:value-of select="@var_value"/>
      </xsl:when>
    </xsl:choose>

</xsl:if>

</xsl:template>

Let me know if it does not make sense.

best,
-Rob



Fabio Cuomo wrote:
Hi at all,
i've a problem with outputting special chars with xsl, particularly
given the following :

<a href="#" tabindex="<?=$tabindex++?>">

rather i want to generate all my link tags with dynamic tabindex
attribute. In xsl i have

<xsl:stylesheet ........
<xsl:output method="html"/>
......
......
<a href=#" tabindex="&#60;?$tabindex++?&#62;">......</a>
.....
.....
</xsl:stylesheet>

but the output produced is :

<a href=#" tabindex="&lt;?$tabindex++?&gt;">....</a>

that is not good because HTML page produced can't be execute
served-side while all php-let are printed in HTML page.
I tried in this way too:

<a href=#">
<xsl:attribute name="tabindex">
    <xsl:text disable-output-escaping="yes">&lt;?$tabindex++?&gt;</xsl:text>
</xsl:attribute>
</a>

but i obtain same result. Note that if i put <xsl:text disable-output-escaping="yes">&lt;?$tabindex++?&gt;</xsl:text>
on xsl not inside attribute, i get correct result. I think problem
concerne special chars inside attribute, problably there must be a
method that i dont'know to put correctly special chars in attribute
value.


Please help me, i'm in trouble.
ANy kind of help is granted.
regards,
Mulp.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.