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

RE: Processing single tag inside mixed complex element

Subject: RE: Processing single tag inside mixed complex element
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 7 May 2007 20:14:21 +0100
RE:  Processing single tag inside mixed complex element
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="{@id}.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@xxxxxxxxx] 
> Sent: 07 May 2007 19:59
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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.

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.