Page 1 of 1

adding and remove element in text node

Posted: Fri Sep 14, 2018 8:45 am
by kumarkumar
Hi All,

I am new to XSLT and struggling to get my expected output. Here what am expecting:

Input 1:
<s>xxxx <d>dddd</d> zzzz</s>
Output for 1:
<p><t>xxxx dddd zzzz</t></p>

Input 2
<s>xxxx <f>dddd</f> zzzz</s>
Output for 2:
<p><t>xxxx </t><t>dddd</t><t> zzzz</t></p>

Could you anybody please help with me?

Thanks,
Kumar

Re: adding and remove element in text node

Posted: Fri Sep 14, 2018 1:32 pm
by Martin Honnen
So what are the exact rules for the transformation, even if you can't express them as XSLT?

For the first sample you simply want to map the "s" element to a "p" and then wrap all the contents of the "s" element additionally into a "t" element which can be easily done with

Code: Select all

<xsl:template match="s">
<p>
<t>
<xsl:apply-templates/>
</t>
</p>
</xsl:template>
then you simply need to add

Code: Select all


<xsl:template match="s/d">
<xsl:apply-templates/>
</xsl:template>
For the second example I am not sure what are the rules and how it relates to the first.