xsl-list
[Top] [All Lists]

Re: [xsl] create escaped(?) html of some nodes

2006-10-10 01:29:38
Jan Limpens wrote:

  Hi

but I have no Idea how I can transform using

      <xsl:template match="entry:Image">
              <p class="ImageParagraph">
                      <img src="{$application-path}{(_at_)href}" 
alt="{entry:Title}" />
                      <br />
                      <xsl:value-of select="entry:Description" />
              </p>
      </xsl:template>

and escape the html (make the brackets become %lt;) as well.

  You have two main options: 1/ create the nodes for resulting HTML,
then serialize them, or 2/ create directly text nodes.  1/ will looks
to something like this:

    <xsl:template match="entry:Image">
      <xsl:text>  &_lt;p class="ImageParagraph"&_gt;</xsl:text>
        <xsl:text>    &_lt;img src="</xsl:text>
        <xsl:value-of select="$application-path"/>
        <xsl:value-of select="@href"/>
        <xsl:text>" alt="</xsl:text>
        <xsl:value-of select="entry:Title"/>
        <xsl:text>"/&_gt;</xsl:text>
        <xsl:text>    &_lt;br/&_gt;</xsl:text>
        <xsl:value-of select="entry:Description"/>
      <xsl:text>  &_lt;/p&_gt;</xsl:text>
    </xsl:template>

  For 2/, you have to use you prefered xx:node-set() extension or XSLT
2.0.  You then create the template rules that make the escaping, in a
particular mode:

    <xsl:template match="*" mode="serialize">
      <xsl:text>&_lt;</xsl:text>
      <xsl:value-of select="name()"/>
      <xsl:apply-templates select="@*" mode="serialize"/>
      <xsl:text>&_gt;</xsl:text>
      <xsl:apply-templates select="node()" mode="serialize"/>
      <xsl:text>&_lt;/</xsl:text>
      <xsl:value-of select="name()"/>
      <xsl:text>&_gt;</xsl:text>
    </xsl:template>

  Or you can use your favorite serialize extension or module.

  Regards,

--drkm
























        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Demandez à ceux qui savent sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--