adding and remove element in text node

Here should go questions about transforming XML with XSLT and FOP.
kumarkumar
Posts: 1
Joined: Fri Sep 14, 2018 8:38 am

adding and remove element in text node

Post by kumarkumar » Fri Sep 14, 2018 8:45 am

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

Martin Honnen
Posts: 52
Joined: Tue Aug 19, 2014 12:04 pm

Re: adding and remove element in text node

Post by Martin Honnen » Fri Sep 14, 2018 1:32 pm

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.

Post Reply