XSLT parser/content error xml to text for doctype cesAlign -
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:output method="text" encoding="utf-8" /> <xsl:template match="linkgrp"> <xsl:value-of select="normalize-space()"/> <xsl:text>
</xsl:text> <!-- newline after sentences --> </xsl:template> </xsl:stylesheet>
when attempt run above xslt stylesheet on following cesalign xml doc
<?xml version="1.0" encoding="utf-8"?> <!doctype cesalign public "-//ces//dtd xml cesalign//en" ""> <cesalign version="1.0"> <linkgrp targtype="s" fromdoc="en/1976/7277/69682_1of1.xml.gz" todoc="zh/1976/7277/4041906_1of1.xml.gz"> <link id="sl0" xtargets=";1" /> <link id="sl1" xtargets="1;2" /> <link id="sl2" xtargets="2;3" /> ...
i encounter error:
parser error : content error in external subset <!doctype cesalign public "-//ces//dtd xml cesalign//en" "">
is there place should specifying particular input doc type (cesalign)?
as i'm not sure expected output should - <xsl:value-of select="normalize-space()"/>
result in nothing function should applied on string , not on node - wrote small xslt getting attribute values, text identifiers. specifying input doc type wasn't needed:
<?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="text" encoding="utf-8" /> <xsl:template match="/*"> <xsl:apply-templates select="linkgrp "/> </xsl:template> <xsl:template match="linkgrp"> <xsl:text>linkgrp
</xsl:text> <xsl:text>targtype: </xsl:text><xsl:value-of select="./@targtype"/> <xsl:text>, fromdoc: </xsl:text><xsl:value-of select="./@fromdoc"/> <xsl:text>, todoc: </xsl:text><xsl:value-of select="./@todoc"/> <xsl:apply-templates select="./link"/> </xsl:template> <xsl:template match="link"> <xsl:text>

link
id: </xsl:text> <xsl:value-of select="./@id"/> <xsl:text>, xtargets: </xsl:text> <xsl:value-of select="./@xtargets"/> </xsl:template> </xsl:stylesheet>
result (todoc
moved manually better readability):
linkgrp targtype: s, fromdoc: en/1976/7277/69682_1of1.xml.gz, todoc: zh/1976 /7277/4041906_1of1.xml.gz link id: sl0, xtargets: ;1 link id: sl1, xtargets: 1;2 link id: sl2, xtargets: 2;3
in case required output should totally different update in question it's not clear if attribute values of link groups , links or kind of copy of whole nodes.
for reference: http://www.w3.org/tr/xpath-functions/#func-normalize-space
Comments
Post a Comment