Absolutely yes, XSLT template rules are designed for exactly this job.
Define one template rule that copies things unchanged:
<xsl:template match="*" mode="html">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="html"/>
</xsl:copy>
</xsl:template>
Add a template rule that handles the fddLink element:
<xsl:template match="fddLink" mode="html">
<a href="{(_at_)id}(_dot_)html>
<xsl:apply-templates mode="html"/>
</a>
</xsl:template>
And then you're all set:
<xsl:template match="description">
<xsl:apply-templates mode="html"/>
</xsl:template>
(The mode probably isn't essential, it depends what else your stylesheet is
doing)
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Ignacio Garcia [mailto:igcxslt(_at_)gmail(_dot_)com]
Sent: 07 May 2007 19:59
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Processing single tag inside mixed complex element
Hello,
I have the following situation:
I have a complex element that resembles some HTML elements
inside it, so it can be used as a text field with HTML-like
tags allowed for formatting.
The HTML elements allowed are br, p, i, b, a (with href).
This element type (notesText) is used inside several places
of my schema.
For example, one element that is of type notesText is "description".
If I want to use XSLT to show the "description" element, I
just use <xsl:copy-of select="./descripton/node()" /> and
everything perfect on the output and everything works as
expected with the HTML like elements working on the HTML output.
HOWEVER, I also have an special element inside this
notesText complexType. The element is called fddLink.
The fddLink is a mixed complex type that has one attribute called ID.
If I output the contents of description directly when
containing and fddLink element, I need to process this
fddLink and transform it into an anchor element.
I could use the ANCHOR element directly, but since fddLink
refers to an special link, it has to be represented
differently in the XML.
My question is... is there any way to process this fddLink
element inside a description element and mantain it's
position and all the other HTML like tags working??
Here is an example of how a description would look like in XML:
---
<description>
Here is a description, that can contain <b>bold text>,
with page breaks<br /><br />
And also <a href="foo.com">links</a>. With an <fddLink
id="fdd0000232">special link</fddLink> on it.
</description>
---
The output should be like this:
----
Here is a description, that can contain <b>bold text>, with
page breaks<br /><br /> And also <a
href="foo.com">links</a>. With an <a
href="fdd0000232.html">special link</a> on it.
----
Thank you.
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--