Hi all,

 

I’m using Xalan J, and though I don’t have a particular problem with the implementation of Xalan I’m having troubles implementing one of the requirements for our project,  I’m even not sure if is at all possible to do it applying only XSL transformations.

Can anyone advise me on this one:

 

I have the following input xml document:

<RESULT>

  <PARAMETERS>

    <CYCLE>

      <ENDDATE>20060215</ENDDATE>

    </CYCLE>

    <FILE><CHECK/></FILE>

  </PARAMETERS>

  <OUTPUT>

    <FILE>b</FILE>

    <FILENAME>E:\ftphome\vodafone\xml\CC20060215S50.XML</FILENAME>

  </OUTPUT>

</RESULT>

 

Now, the resulting xml should have the FILE and FILENAME tags belonging to OUTPUT element transferred to PARAMETERS element, which I can do with no effort at all with the following template:

<--! Coy input node to the output -->
<xsl:template match="*">

<xsl:copy>

<xsl:apply-templates />

</xsl:copy>

</xsl:template>

<xsl:template match="OUTPUT"></xsl:template> <!--Output node is not copied to output -->

<--! Copy output nodes to Parameters element -->

<xsl:template match="/RESULT/PARAMETERS">

<xsl:copy>

<xsl:copy-of select="/RESULT/OUTPUT/*" />

<xsl:apply-templates />

<xsl:copy>

</xsl:template>

 

The tricky thing here, is that if the FILE/FILENAME tag (or any tag under OUTPUT) exists under PARAMETERS, then the tag under PARAMETERS should be overwritten by correspondent OUTPUT tag. In this case the correct output should be the following:

<RESULT>

  <PARAMETERS>

    <CYCLE>

      <ENDDATE>20060215</ENDDATE>

    </CYCLE>

   <FILE>b</FILE>

   <FILENAME>E:\ftphome\vodafone\xml\CC20060215S50.XML</FILENAME>

  </PARAMETERS>

</RESULT>

 

I would much appreciate some help, and since I’m not sure I’m using the right mailing list, please accept my apologies and please guide to a correct one.

 

Many many thanks

Higino Silva

 

AVISO

Esta mensagem e quaisquer anexos seus podem conter informação confidencial para uso exclusivo do destinatário. Cabe ao destinatário assegurar a verificação de vírus e outras medidas que assegurem que esta mensagem não afecta os seus sistemas. Se não for o destinatário, não deverá usar, distribuir ou copiar este e-mail, devendo proceder à sua eliminação e informar o emissor. É estritamente proibido o uso, a distribuição, a cópia ou qualquer forma de disseminação não autorizada deste e-mail e seus anexos. Obrigado.

 

DISCLAIMER

This e-mail and its attachments may contain confidential information for exclusive use of its recipient. It is your responsibility to carry out appropriate virus and other checks to ensure that this message and any attachments do not affect your systems / data. If you are not the intended recipient you must not use, distribute or reproduce this e-mail and you must notify the sender and delete the entire email. Any unauthorized use, dissemination, distribution or copying of this message and its attachments is strictly prohibited. Thank You.

Reply via email to