0

I have an XML file in some format and want to convert it into another format.

The first format is :

<Project>
 <Requirements>
  <Source>     
    <Section>
      <Requirement>
        <Content>
          this is I<sub>leakage</sub>
        </Content>
        <Title></Title>
        <Property name="Status"/>
      </Requirement>
   </Section>
  </Source>
 </Requirements>
</Project>

And I'm using a template to change this sub tags into subscript tags

      this is I<sub>leakage</sub>

to

      this is I<subscript>leakage</subscript>

and I'm using this template to convert:

<xsl:template match="sub">
   <Subscript>
       <xsl:value-of select="current()/text()"/>
   </Subscript>
</xsl:template>

problem is the template isn't working , Although if I put the sub tags out side the Requirement(for example under Section) it works fine.

Any ideas how to fix this ?

Mohamed Ahmed
  • 27
  • 2
  • 7
  • 1
    If it works when you move the `sub` tags out of `Requirement`, something isn't getting processed. You need to show more of your XSLT. (A working example at least.) – Daniel Haley Nov 14 '14 at 20:50
  • 1
    To say that in another way, there is probably no apply-templates instruction that selects the sub elements for processing. – Michael Kay Nov 14 '14 at 22:12

1 Answers1

0

Hope this helps,

<xsl:template match="sub">
 <Subscript>
  <xsl:value-of select="./text()"/>
 </Subscript>
</xsl:template>

This worked at my end. Reason for difference can be found here: Current node vs. Context node in XSLT/XPath?

Community
  • 1
  • 1
Saurav
  • 592
  • 4
  • 21