Jump to content

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


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...