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)
> 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