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

Re: Tag within tag

Subject: Re: Tag within tag
From: Peter Flynn <peter@xxxxxxxxxxx>
Date: 05 Apr 2003 00:18:40 +0100
xsl value of within tag
On Fri, 2003-04-04 at 22:48, David B. Bitton wrote:
> I have the following XML:
> 
> <body>
> 	Subscriber agrees to pay Company the sum of $
> 	<sub name="install" />
> 	, plus tax, if applicable, for the installation (and sale if the System 
> is sold) of the System as follows: $
> 	<sub name="down_pmt" />
> 	upon signing this Agreement; $
> 	<sub name="pre_wire_pmt" />
> 	upon pre-wiring, if necessary; $
> 	<sub name="final_pmt" />
> 	upon substantial completion of installation.
> </body>
> 
> I have the following template for the <body> element:
> 
> <xsl:template match="body">
> 	<fragment font="Helvetica" fontsize="7">
> 		<xsl:value-of select="."/>
> 	</fragment>		
> </xsl:template>
> 
> but I don;t know how to handle a <sub> element within <body> if it 
> occurrs.  What do I need to do?  BTW, XPath 1.0 :)

Don't use value-of for processing the normal content of elements,
and especially not where there are subelements. Value-of simply
extracts the string value, ignoring all element markup, which is
the opposite of what you want. Instead, use <xsl:apply-templates/>
which means "process the content of this element using any
further templates that apply". Create a template to match "sub"
and put in it whatever is relevant.

But you have a more serious problem, I think: all that extraneous
white-space is going to cause problems if you are producing formatted
output, because you'll have a space after every dollar sign, which
in some circumstances may cause line-breaks to occur in unwanted
locations. Fix the XML so it says:

  <body>Subscriber agrees to pay Company the sum of $<sub 
  name="install"/>, plus tax, if applicable, for the 
  installation (and sale if the System is sold) of the 
  System as follows: $<sub name="down_pmt"/> upon signing 
  this Agreement; $<sub name="pre_wire_pmt"/> upon 
  pre-wiring, if necessary; $<sub name="final_pmt"/>
  upon substantial completion of installation.</body>

or similar. 

///Peter



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.