xsl-list
[Top] [All Lists]

RE: XSL copy-of problem with extraction of a node based on child element

2005-01-20 02:00:38
Instead of

<xsl:copy-of select="contents/property/index[. = '003000001']"/>

you want

<xsl:copy-of select="contents/property[index = '003000001']"/>

The first selects an index whose value is 003000001. The second selects a
property whose index child has the value 003000001.

Michael Kay
http://www.saxonica.com/

 

-----Original Message-----
From: Carroll, David 
[mailto:David(_dot_)Carroll(_at_)am(_dot_)sony(_dot_)com] 
Sent: 20 January 2005 04:32
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: [xsl] XSL copy-of problem with extraction of a node 
based on child element



I wish to extract one subnode from an XML file based on the 
value of a child
element in the node. In this case a complete copy of a 
property node based
on the value of the index element. My efforts so far have 
either resulted in
the index element only or the entire XML file.

 

Thanks for your help.

 

David 

 

 

 

XML FILE

 

<?xml version="1.0" encoding="UTF-8"?>

<contents ver="1.0">

   <type>telop</type>

   <count>13</count>

   <property>

         <index>003000001</index>

         <cdate>2004-10-23 12:27:03.015</cdate>

         <size>34614</size>

         <info>Text</info>

         <title>UPDATE: 10 minute delay Concord to San F</title>

         <width>479</width>

         <height>24</height>

         <lineheight>24</lineheight>

         <format>BITMAP</format>

         <effect row="1" col="1">1</effect>

         <effect row="1" col="2">50</effect>

         <effect row="2" col="1">0</effect>

         <effect row="2" col="2">0</effect>

         <effect row="2" col="3">0</effect>

         <effect row="3" col="1">0</effect>

         <effect row="4" col="1">1</effect>

         <effect row="4" col="2">0x000000</effect>

   </property>

   <property>

         <index>003000002</index>

         <cdate>2004-10-20 17:20:16.078</cdate>

         <size>39606</size>

         <info>Text</info>

         <title>Buy your Commute Pass this week and save</title>

         <width>549</width>

         <height>24</height>

         <lineheight>24</lineheight>

         <format>BITMAP</format>

         <effect row="1" col="1">1</effect>

         <effect row="1" col="2">50</effect>

         <effect row="2" col="1">0</effect>

         <effect row="2" col="2">0</effect>

         <effect row="2" col="3">0</effect>

         <effect row="3" col="1">0</effect>

         <effect row="4" col="1">1</effect>

         <effect row="4" col="2">0x000000</effect>

   </property>

</contents>

__________________________________

 

XSL

 

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="xml" indent="yes"/>

 

<xsl:template match="/">

<xsl:copy-of select="contents/property/index[. = '003000001']"/>

 </xsl:template>

</xsl:stylesheet>

 

 

 

 

 



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




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