I have a java program which goes through a directory of xml files and extracts certain nodes using a xsl stylesheet.
Everything works except the xsl is pulling some extra text that I don't want and I don't know how to get rid of it.
<testimonial>
<author>Bob</author>
<location>Ottawa</location>
<pageHeading>Bob in Ottawa</pageHeading>
<quote>Work is fun</quote>About CFPSA5/9/2005CFCF\tsi
<link>test.asp</link>TestimonialsenglishCFCF\tsi5/9/2005_selftrue
</testimonial>
The above is what I'm getting from applying the xsl to a single xml file but what I want is:
<testimonial>
<author>Bob</author>
<location>Ottawa</location>
<pageHeading>Bob in Ottawa</pageHeading>
<quote>Work is fun</quote>
<link>test.asp</link>
</testimonial>
The extra text is from other nodes of the xml but I'm not extracting them using the xsl and I can't figure out how to get rid of it.
The xsl is below
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:strip-space elements="/"/>
<xsl:template match="/">
<testimonial>
<xsl:apply-templates />
</testimonial>
</xsl:template>
<xsl:template match="/page/english/author">
<author> <xsl:value-of select="."/> </author>
</xsl:template>
<xsl:template match="/page/english/location">
<location> <xsl:value-of select="."/> </location>
</xsl:template>
<xsl:template match="/page/english/quote">
<quote> <xsl:value-of select="."/> </quote>
</xsl:template>
<xsl:template match="/page/english/page_heading">
<pageHeading> <xsl:value-of select="."/> </pageHeading>
</xsl:template>
<xsl:template match="/page/metadata/dcrName">
<link> <xsl:value-of select="."/> </link>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="normalize-space()"/>
</xsl:template>
</xsl:stylesheet>
the xml source files look like this:
<?xml version="1.0" encoding="UTF-8"?>
<page>
<english>
<choose>
<heading/>
</choose>
<choose>
<paragraph/>
</choose>
<author>abc</author>
<location>def</location>
<page_heading/>
<quote>aaaaaaa</quote>
</english>
<french>
<choose>
<heading/>
</choose>
<choose>
<paragraph/>
</choose>
<author/>
<location/>
<page_heading/>
<quote/>
</french>
<metadata>
<area>About CFPSA</area>
<creation_date>5/9/2005</creation_date>
<creator>CFCF\tsi</creator>
<dcrName>daf</dcrName>
<dcrType>Testimonials</dcrType>
<description/>
<expiration_date/>
<keywords/>
<language>english</language>
<last_modified_by>CFCF\tsi</last_modified_by>
<last_modified_date>5/9/2005</last_modified_date>
<parent/>
<target>_self</target>
<touched>true</touched>
</metadata>
</page>
I could use something like this:
http://www.w3schools.com/xsl/xsl_value_of.asp
but that would generate a
<?xml version="1.0" encoding="ISO-8859-1"?>
for each xml in the directory which I don't want.