[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Copy part of the file if some conditions are applied

Subject: Copy part of the file if some conditions are applied
From: "brigadasinter@xxxxxxxxxxxx" <brigadasinter@xxxxxxxxxxxx>
Date: Wed, 7 Jun 2006 21:09:27 -0300 (ART)
copy part of file
Hi,

I want to copy some parts of the tree, under certains
conditions, for example:

    <tagA>
      <tagB type="single">
        <pred>R_DoInitiali__T__ation</pred>
      </tagB>
      <tagC>
        <tagD type="single">
          <pred>NavG__z__Box</pred>
          <const name="eq">
            <arg>halfSide</arg>
          </const>
        </tagD>
        <tagD>
          <pred>NavBox</pred>
          <const name="eq">
            <arg>halfSide</arg>
          </const>
        </tagD>
        <tagE type="single">
          <pred>NavGBox</pred>
          <const name="eq">
            <arg>halfSide</arg>
          </const>
        </tagE>
      </tagC>
    </tagA>

If <pred> in <tagB> contains the caracter 'z' then
nothing should be copy from the <tagA> (and that
<tagA> should not appear in the transformation).
Otherwise, I have to check if any <pred> tag inside
<tagC> contains 'z', in that case, I cannot copy
anyhing from the father tag (D or E). That is, the
transformation would be:

    <tagA>
      <tagB type="single">
        <pred>R_DoInitiali__T__ation</pred>
      </tagB>
      <tagC>
      <!-- The <tagD>  with NavG__z__Box value   is
not copy -->
       <tagD>
          <pred>NavBox</pred>
          <const name="eq">
            <arg>halfSide</arg>
          </const>
        </tagD>
       <tagE type="single">
          <pred>NavGBox</pred>
          <const name="eq">
            <arg>halfSide</arg>
          </const>
        </tagE>
      </tagC>
    </tagA>

Is important to mention that in case I have just one
<tagD> inside <tagC>, and that <tagD> contains 'z',
nothing including <tagA> should be copied. 

    <tagA>
      <tagB type="single">
        <pred>R_DoInitiali__T__ation</pred>
      </tagB>
      <tagC>
       <tagD>
          <pred>NavBox__Z__</pred>
          <const name="eq">
            <arg>halfSide</arg>
          </const>
        </tagD>
       </tagC>
    </tagA>

(The result for this <tagA> is blank. Nothing can be
copied).

I am using: the <copy> template as follows but I just
copy part of the tags, but not the completely <tagA>
when in <tagD> there is no 'z'. 

<xsl:template match="tagA">
  <xsl:choose> 
   <xsl:when test=" ... "> <!--Check if pred in tagB
does not contains 'z' -->
          <xsl:for-each select="tagB/*/pred">
            <xsl:choose> 
             <xsl:when test=" ..."> <!--Check if pred
inside tagD  does not contains 'z' -->
                <xsl:copy> 
                  <xsl:apply-templates select=" @* |
node()"/> <!--This only copy tagD/E, but I also want
tagA and tagB -->
                </xsl:copy>
             </xsl:when>
            </xsl:choose>
       </xsl:for-each>    
   </xsl:when>
 </xsl:choose>
</xsl:template> 

Can anyone help me? 
Sorry for the long e-mail. 
Maria

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam !gratis! 
!Abrm tu cuenta ya! - http://correo.yahoo.com.ar

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.