P
pradeep gummi
I have an XML FILE that is to be converted to Plain Text using an XSL
file. Since I just want plain text, I do not want to set any root
element during transformation.And if I do not any root element during
transformation, it return s "java.lang.IllegalStateException: Root
element not set" exception. If I add any element for the enclosed
root, it works.
Note: I am using XMLOutputter object of JDOM API, packages
javax.xml.transform and javax.xml.transform.stream.*
Example XML file:
<root><nextpart>test</nextpart></root>
*******************XSL FILE that returns
exception*****************************
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="text" indent="yes"/>
<xsl:template match="root">
<xsl:text>Hello This is the content.</xsl:text>
<xsl:apply-templates select="nextpart"/>
</xsl:template>
...........
</xsl:stylesheet>
************************xsl file****************************
***********************XSL FILE modified*****************************
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="text" indent="yes"/>
<xsl:template match="root">
<document>
<xsl:text>Hello This is the content.</xsl:text>
<xsl:apply-templates select="nextpart"/>
</xsl:template></document>
........
</xsl:stylesheet>
************************xsl file****************************
This change would generate an output:
<document>Hello This is the content.</document>
But I would just want the text without <document> tag.
Any suggestions
thanks
pradeep
file. Since I just want plain text, I do not want to set any root
element during transformation.And if I do not any root element during
transformation, it return s "java.lang.IllegalStateException: Root
element not set" exception. If I add any element for the enclosed
root, it works.
Note: I am using XMLOutputter object of JDOM API, packages
javax.xml.transform and javax.xml.transform.stream.*
Example XML file:
<root><nextpart>test</nextpart></root>
*******************XSL FILE that returns
exception*****************************
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="text" indent="yes"/>
<xsl:template match="root">
<xsl:text>Hello This is the content.</xsl:text>
<xsl:apply-templates select="nextpart"/>
</xsl:template>
...........
</xsl:stylesheet>
************************xsl file****************************
***********************XSL FILE modified*****************************
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="text" indent="yes"/>
<xsl:template match="root">
<document>
<xsl:text>Hello This is the content.</xsl:text>
<xsl:apply-templates select="nextpart"/>
</xsl:template></document>
........
</xsl:stylesheet>
************************xsl file****************************
This change would generate an output:
<document>Hello This is the content.</document>
But I would just want the text without <document> tag.
Any suggestions
thanks
pradeep