adding and remove element in text node

Here should go questions about transforming XML with XSLT and FOP.
kumarkumar
Posts: 1

adding and remove element in text node

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: 43

Re: adding and remove element in text node

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.

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest