[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Tag 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|