Subject: [xsl] 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) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML subset selection-a si, Jeni Tennison | Thread | Re: [xsl] Copy part of the file if , Jeni Tennison |
RE: [xsl] url encoding gets wrong w, Nathan Young -X \(na | Date | [xsl] Save value in variable or par, Niklas Holmberg |
Month |