|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Xalan to transform only selected elements of XML
> So the question is:
> how can I transform only selected elements and not >
> all elements of XML?
Thanks to Morten Primdahl, Mike Brown and Heather
Lindsay for your inputs.
Morten -- Your suggestion is valid, but is there a
generic solution?
such that I do not have to change my .XSL file every
time I have new element in XML file,
that I do not want in the resulting transoformation.
Mike -- The elements in XML file do not have any
attributes. i.e.
My XML is:
---------
<?xml version="1.0"?>
<Policy>
<Insured>
<FirstName>John</FirstName>
<MI>A.</MI>
<LastName>Smith</LastName>
<Address1>123 Bumpy Fast Lane</Address1>
<State>MI</State>
<Zip>12345</Zip>
</Insured>
</Policy>
My XSL is:
---------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Policy">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Insured">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="FirstName">
<b>First Name:</b>
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="LastName">
<b>Last Name:</b>
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="Zip">
<b>Zip:</b>
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
But, undesired Result is :
------------------------
<b>First Name:</b>John
A.
<b>Last Name:</b>Smith
123 Fast Lane
MI
<b>Zip: 12345</b>
My Desired Result:
------------------
<b>First Name:</b>John
<b>Last Name:</b>Smith
<b>Zip:</b>12345
How can I reach to my desired result?
Thanks for your help.
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
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
|

Cart








