1,105,447 Community Members

Node not being matched to template

Member Avatar
Mike Askew
Posting Shark
927 posts since Nov 2010
Reputation Points: 129 [?]
Q&As Helped to Solve: 85 [?]
Skill Endorsements: 25 [?]
Featured
 
0
 

Firstly I will say im a complete and total novice when it comes to XSLT and XML so this could be a very obvious mistake on my behalf.

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="node()">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="TestNode">
    <RenamedNode>
      <xsl:copy-of select="."/>
    </RenamedNode>
  </xsl:template>

</xsl:stylesheet>

When running the above, even though <TestNode> exists it does not match and rename the node and I cannot figure out why :/

Is anyone able to shed some light on why this is the case?

Thanks in advance

Member Avatar
StephNicolaou
Posting Whiz in Training
204 posts since Nov 2007
Reputation Points: 32 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

Can you please post your XML? I would initially check your node names and structure.

Member Avatar
Mike Askew
Posting Shark
927 posts since Nov 2010
Reputation Points: 129 [?]
Q&As Helped to Solve: 85 [?]
Skill Endorsements: 25 [?]
Featured
 
0
 

I cannot post the actual XML due to what it is used for however I will quickly recreate the structure of the document.

<T>
 <A>
  <B>
   <1></1>
   <2></2>
  </B>
  <C>
   <1></1>
   <2></2>
  </C>
 </A>
 <D>
  <E>Data</E>
  <TestNode>Data</TestNode>
 </D>
</T>
Member Avatar
Mike Askew
Posting Shark
927 posts since Nov 2010
Reputation Points: 129 [?]
Q&As Helped to Solve: 85 [?]
Skill Endorsements: 25 [?]
Featured
 
0
 

Problem has been solved. It was an issue to do with the namespace the XML used (wasnt aware this had an impact due to inexperience with XSL)

:)

Question Answered as of 2 Years Ago by StephNicolaou
Member Avatar
StephNicolaou
Posting Whiz in Training
204 posts since Nov 2007
Reputation Points: 32 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

Okay that's good news! I thought so, it has to match correctly with the XSL :)

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: