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

RE: How to parse an element with content and child-elements

Subject: RE: How to parse an element with content and child-elements
From: sara.mitchell@xxxxxxxxx
Date: Mon, 6 Mar 2000 14:40:06 -0500
parse an element
This is very simple -- you use two templates. For example:
 
<xsl:template match="content">
 <p>
  <xsl:apply-templates/>
</p>
</xsl:template>
 
This one put in the P tags around the content and processes any children (both text AND other
elements). Text simply comes out as text (there's a default template for text). Any other child
element comes out matching a template for that child if you provide it. So you're other template
would be this:
 
<xsl:template match="other-content">
 <br/>
  <font color="red">
    <xsl:apply-templates/>
  </font>
 <br/>
</xsl:template>
 
When the XSL processor finds the Other-content tag, it looks for the second template
and inserts the BR and Font tags. The <xsl:apply-templates> tag inside of the template
for Other-content simply makes sure that the text children or any other element children
are also formatted and output.
 
Sara
-----Original Message-----
From: Kai Ritterbusch [mailto:kai@xxxxxxxxxxxxxxxxxxx]
Sent: Saturday, March 04, 2000 7:21 AM
To: XSL-List
Subject: How to parse an element with content and child-elements

Hi,
I want to parse XML-elements wich contain text AND other elements (Example). the stylesheet should print the value
of the element (Example: content), and if it passes a child element it should format this with new rules. it is important that the child element stays at his place in the text.
 
Im sure this is possible, but i have no idea how to realize :(
 
My Example:
 
DTD:
<!ELEMENT content ( #PCDATA | other-content ) >
 
 
XML-File:
 
<xml-file>
<content>
    blablabla bla bla bla bla  
        <other-content>blub etc etc etc</other-content> 
    bla bla bla
</content>
</xml-file>
 
 
 
I want to format this XML code into HTML:
 
<p>
blablabla bla bla bla bla 
    <br/>
       <font color="red">blub etc etc etc</font>
    <br/>
bla bla bla
</p>
 
thanks for any help
 
    Kai Ritterbusch
 
 
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.