Reputation: 1289
I am new to XSLT. I am working transforming an XML file from one format to another format. I also want to extract values from an element and display the them in bold format.
Sample source XML:
<Content xmlns="uuid:4522eb85">
<first xmlns="uuid:4522eb85">Hello World. This is first field</first>
<second author="XYZ">Hi iam second field</second>
</Content>
Output format required:
<root>
<aaa>Hello World. This is first field</aaa>
<bbb><author>**XYZ**</author>Hi iam second field</bbb>
<root>
I am unable to extract attributes from a tag and display with style(say bold).
Please help. Thank you in advance.
Upvotes: 0
Views: 3139
Reputation: 599581
This XSLT outputs exactly what you ask for.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:c="uuid:4522eb85" exclude-result-prefixes="c">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/c:Content">
<root>
<aaa><xsl:value-of select="c:first"/></aaa>
<bbb><author>**<xsl:value-of select="c:second/@author" />**</author><xsl:value-of select="c:second" /></bbb>
</root>
</xsl:template>
</xsl:stylesheet>
But as Jeremy suggests, you may want to consider first taking an (online) XSLT training if you want to get much further.
Upvotes: 3
Reputation: 3967
If you want to display the text with style then you have to display the content in html. You should use XSLT to get the info from XML and create a HTML output with you required style
Upvotes: 1