I have an xml source that I would like recreate with some modifications. Specifically, I would like to modify attribute values based on a condition. I'm able to recreate the XML file but it's the modifications that I'm having difficulties with.
For example, based on the xml sample below, if PARA Style = "Section_Title", I would like to:
1) Change the value for the align attribute from "left" to "right" and
2) Change the text from "This is My Title" to "Book Title"
Any help would be greatly appreciated.
My XML file is as follows...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MYROOT>
<BODY>
<SECTION>
<PARA Style="Section_Title" align="left" emphasis-bold="true">This is My Title </PARA>
<PARA Style="Body" align="left">
<STEXT font="Arial" hidden="true">This is some special text</STEXT>
<LINK Style="Body Text" align="left"> </PARA>
</SECTION>
</BODY>
</MYROOT>
So far I'm only able to recreate the same XML file using the following XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="*|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:copy>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>
Thanks.
For example, based on the xml sample below, if PARA Style = "Section_Title", I would like to:
1) Change the value for the align attribute from "left" to "right" and
2) Change the text from "This is My Title" to "Book Title"
Any help would be greatly appreciated.
My XML file is as follows...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MYROOT>
<BODY>
<SECTION>
<PARA Style="Section_Title" align="left" emphasis-bold="true">This is My Title </PARA>
<PARA Style="Body" align="left">
<STEXT font="Arial" hidden="true">This is some special text</STEXT>
<LINK Style="Body Text" align="left"> </PARA>
</SECTION>
</BODY>
</MYROOT>
So far I'm only able to recreate the same XML file using the following XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="*|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:copy>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>
Thanks.