Jump to content

[xslt-1.0]how To Treat The Same Tag At Different Level In The Xml Tree


sacha74
 Share

Recommended Posts

I would like to delete the <DIV> tags while keeping all the tags that are in the <Div> tag. The problem is that in the code there are <DIV> tags in other <DIV> tags.The original code:

<XML><Map-Start><A ID="pgfId-592691"/></Map-Start>	<Bloc-paragraphe><A ID="pgfId-596086"/>074 is used to customise application codes for the administration of time and call fiduciary deposit orders. </Bloc-paragraphe><Map><A ID="pgfId-596087"/>information </Map>	<Bloc-paragraphe>		<A ID="pgfId-596106"/>ggjug guigik	</Bloc-paragraphe><DIV>		<IMAGE xml:link="simple" href="074-1.gif" show="embed" actuate="auto"/>	</DIV>	<DIV>		<FM2Titre><A ID="pgfId-596112"/>access key</FM2Titre>		<DIV>			<FM3Titre><A ID="pgfId-596113"/></FM3Titre>			<Bloc-paragraphe><A ID="pgfId-596114"/>position to: </Bloc-paragraphe>			<DIV>				<Liste-Puce><A ID="pgfId-596115"/>a new application code,</Liste-Puce></DIV></DIV></DIV></XML>

My xslt:

<xsl:template match="node()">	<xsl:copy>	<xsl:apply-templates select="node()"/>	</xsl:copy>	</xsl:template>	<xsl:template match="A|T-No|T-######|IMAGE"/>			<xsl:template match="DIV|DIV/DIV|DIV/DIV/DIV">	 <xsl:copy-of select="node()"/>	</xsl:template>

What I would like to obtain:

<XML><Map-Start><A ID="pgfId-592691"/></Map-Start>	<Bloc-paragraphe><A ID="pgfId-596086"/>074 is used to customise application codes for the administration of time and call fiduciary deposit orders. </Bloc-paragraphe><Map><A ID="pgfId-596087"/>information </Map>	<Bloc-paragraphe>		<A ID="pgfId-596106"/>ggjug guigik	</Bloc-paragraphe>		<IMAGE xml:link="simple" href="074-1.gif" show="embed" actuate="auto"/>		<FM2Titre><A ID="pgfId-596112"/>access key</FM2Titre>			<FM3Titre><A ID="pgfId-596113"/></FM3Titre>			<Bloc-paragraphe><A ID="pgfId-596114"/>position to: </Bloc-paragraphe>				<Liste-Puce><A ID="pgfId-596115"/>a new application code,</Liste-Puce></XML>

Can you help me to understand how to treat all the <DIV> tags even those which are DIV/DIV/DIV/DIV.Do you have any ideas?Thanks in advance for all the help I could find.

Link to comment
Share on other sites

It seems like you want the identity template plus a template for 'DIV' elements which processes the child nodes:

<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">    <xsl:template match="@* | node()">	<xsl:copy>	  <xsl:apply-templates select="@* | node()"/>	</xsl:copy>  </xsl:template>    <xsl:template match="DIV">	<xsl:apply-templates/>  </xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...