xsl-list
[Top] [All Lists]

Re: [xsl] Re: XSL issue

2006-07-06 22:24:18
Hi Prashanth,
  You need to do following..

First write a identity template (to copy everything):

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

Now write different templates for various cases:

<xsl:template match="body">
  <body>
     <chunk>
        <xsl:apply-templates />
     </chunk>
  </body>
</xsl:template>

<xsl:template match="a">
  <xsl:choose>
     <xsl:when test="contains(@href, '.com') or contains(@href, '.net')">
        <ulink url="{(_at_)href}" />
     </xsl:when>
     <xsl:otherwise>
        <link linkend="{(_at_)href}" />
     </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Regards,
Mukul

On 7/7/06, Prashanth T S <tsprashanth(_at_)gmail(_dot_)com> wrote:
>
> Hi,
>
>           I have an input xhtml file. There are a couple of things I need to
> do to this file
>
> 1) Between the <body>......................</body> tags, I
> need to add my own custom tag like
> <body><chunk>................</chunk></body>.
>
> 2) If I have a <a href="xyz"> </link>then I need to replace a with link,
> href with linkend.Basically this should become
>                    <link linkend="xyz"></link>.
>
> Also, if the link is referring to an external link, like
> http://www.google.com, then instead of link I must put ulink i.e.,
>                    <ulink url=http://www.google.com> </ulink>
>
> Please let me know if there is a solution for the above. This is very urgent
> and any help would be highly appreciated.
>
> Thanks
> Prashanth

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>