xsl-list
[Top] [All Lists]

Re: Copy missing elements

2005-09-06 09:55:53
You might also like to try this stylesheet(based on identity
transform). I am assuming you mean that 2nd member element does'nt
have email tag, while 1st one has.. If you need a more generic
solution, please let us know..

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
 
<xsl:output method="xml" indent="yes" /> 
 
<xsl:template match="node() | @*">
   <xsl:copy>
     <xsl:apply-templates select="node() | @*" />
   </xsl:copy>
</xsl:template>
 
<xsl:template match="member[2]">
   <member>
     <xsl:copy-of select="*" />
     <email/>
   </member>
</xsl:template>
 
</xsl:stylesheet>

Regards,
Mukul


On 9/6/05, Rick Quatro <frameexpert(_at_)truevine(_dot_)net> wrote:
I have the basic structure.

<list>
   <member>
       <lastname>Jones</lastname>
       <firstname>Frank</firstname>
       <email>frank(_at_)jones(_dot_)com</email>
   </member>
   <member>
       <lastname>Smith</lastname>
       <firstname>John</firstname>
   </member>
</list>

The second <member> does not have an <email> element. I want to duplicate
the structure, but add an empty <email> element to the new xml document, so
it looks like this:

<list>
   <member>
       <lastname>Jones</lastname>
       <firstname>Frank</firstname>
       <email>frank(_at_)jones(_dot_)com</email>
   </member>
   <member>
       <lastname>Smith</lastname>
       <firstname>John</firstname>
       <email></email>
   </member>
</list>

Thank you in advance.

Rick Quatro
Carmen Publishing
585 659-8267
rick(_at_)frameexpert(_dot_)com
www.frameexpert.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>