Jump to content

wickey

Members
  • Content Count

    1
  • Joined

  • Last visited

Posts posted by wickey

  1. Hello,I'm new to xml and xslt, and have a question, probably an easy fix, but I'm not finding a solution very quickly at all.I'm trying to transform a doxygen xml file, just transforming it to the standard xml format I need for some other final transform.Basically, I need to match two child elements with one another, ( paramname with parammsg ) but, both of these have different parent nodes. I can do a transform that will giveeach ( paramname with parammsg ) an unique attribute, but I still don't know how to match those together.Here is a small piece of the xml. I want to extract the paramname and it's respective parammsg, <memberdef><paramlist><paramitem><paramname kind="1"><para>double num1</para></paramname></paramitem><paramitem><paramname kind="2"><para>double num2</para></paramname></paramitem><paramitem><paramname kind="3"><para>double num3</para></paramname></paramitem></paramlist><detaileddescription><parammsg kind="1"><para>This is number 1</para></parammsg><parammsg kind="2"><para>This is number 2</para></parammsg><parammsg kind="3"><para>This is number 3</para></parammsg></detaileddescription></memberdef> So, after the transform I would like to have a form, something like this: <memberdef> <param><row><entry><code>double num1</code></entry><entry>This is number 1 </entry></row><row><entry><code>double num2</code></entry><entry>This is number 2 </entry></row><row><entry><code>double num3</code></entry><entry>This is number 3</entry></row></param></memberdef> Also, if there is a way to match these without using the attribute, that would be of great help aswell.Thank-You for any help or suggestions! Edit: I found a solution to my issue, dont know if this is the right way to do it, but it works for my situation.I used a variable to keep a count <xsl:variable name="cnt"><xsl:number/></xsl:variable> then selected the correct param descriptionwhen it's position() = $cnt. This is my template: <xsl:template match="paramitem"><xsl:variable name="cnt"><xsl:number/></xsl:variable><row><entry> <!-- Parameters and brief descriptions -\-> <!-\- Name -\-> <!-\- Description --><code><xsl:value-of select="paramname "/></code></entry><entry><xsl:value-of select="para/../../../detaileddescription/paramsg[position()= $cnt]/para"/></entry></row></xsl:template> Hope this helps anyone else thats looking for something like this, but if there are better solutions, let me know.

×
×
  • Create New...