Search code examples
htmlxmlxsltxslt-grouping

how to extract partail value of elements and display them in bold/italic/list while converting an xml to html output in xslt


I am working on XML transformations.I have to exctrat velue of an element and display them in bold/italic/list. Source:

 <content>
    <bodyParagraphText>
ABCD<strong   xmlns="http://www.w3.org/1999/xhtml">:<dynamicVariable  name='BOLD'></dynamicVariable></strong>
 </bodyParagraphText>  
 </content>

1.Output required1(bold):

<aaa>
     ABCD **BOLD**
</aaa>

2.Output required1(list):

<aaa>
     ABCD 

 - BOLD

</aaa>

3.Output required1(underline):

  <aaa>
     ABCD BOLD(underlined)
  </aaa>

I am completely new to it. I am not getting any ideas to work on. Please help. Thank you in advance.


Solution

  • Somewhat guessing about what it is you need to do, but:

    • On your xsl:stylesheet element, declare a namespace prefix for xhtml, such as "xhtml".

    • Create a template that matches "content/bodyParagraphText".

    • Use XPath expression "text()[1]" to get the 'ABCD' text, apparently. Put this in a variable, such as abcd.

    • Use XPath expression ".//xhtml:dynamicVariable/@name" to get 'BOLD'. Put this in a variable, such as dv.

    • To specify your output, use something like

    :

    <aaa>
      <xsl:value-of select="$abcd" /> **<xsl:value-of select="$dv" />**
    </aaa>
    

    for the first output format required.

    If I have misunderstood your question, please clarify...