xsl-list
[Top] [All Lists]

Re: Navigating an XML file with xsl:for-each etc.

2005-08-26 08:40:58
Hi Houman,
  Something like

<xsl:for-each select="//*[action='change']">
  <xsl:if test="add and delete">
     <xsl:if test="add/c = delete/c">
        ...
     </xsl:if>
      <xsl:if test="add/d = delete/d">
        ...
      </xsl:if>
  </xsl:if>
</xsl:for-each>

(this is not tested)

Regards,
Mukul

On 8/26/05, Khorasani, Houman <houman_khorasani(_at_)csgsystems(_dot_)com> 
wrote:
Hello everyone,

I have checked the FAQ but couldn't find any solution to this:

I have an XML file like this:

<a>
</a>
<b action='change'>
       <add>
               <c>bla</c>
               <d>bla</d>
       </add>
       <delete>
               <c>bla</c>
               <d>bla</d>
       <delete>
</b>
<e>
</e>


I have to check for each attribute called 'change'
       Then look if it has an <add> tag and an <delete> tag
               - Compare the sub element of <add> called <c> with the
sub                     element of <delete> called <c> and see if the
value is equal.
               - The same with sub element <d>


I guess the best to do that is to use a for-each to check all the
attributes with the value 'change' (This is not working in my example
below though)
1) How do I use for-each with attributes? Like this?

<xsl:for-each select="//[action='change']">
               <xsl:if test=".='add'">
                       ...
               </xsl:if>
               ...
</xsl:for-each>

2) How do I compare in the most efficient way the two sub-elements <c>
and <d> against each other?


Many thanks for any idea,
Houman

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