[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

Subject: Re: Xalan to transform only selected elements of XML
From: "P. DEXTER" <jishow@xxxxxxxxx>
Date: Wed, 31 May 2000 06:31:35 -0700 (PDT)
xslt change only selected element
> 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


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.