开发者

Java SAX parsing: What's wrong with this XML?

I'm trying to validate an XML file, but I get the following error:

Can not find declaration of element 'xsl:stylesheet'.

This is the XML:

<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt' exclude-result-prefixes='msxsl' xmlns:ns='http://www.ibm.com/wsla'>
      <xsl:strip-space ele开发者_如何转开发ments='*'/>
      <xsl:output method='xml' indent='yes'/>
      <xsl:template match='@* | node()'>
            <xsl:copy>
                  <xsl:apply-templates select='@* | node()'/>
            </xsl:copy>
      </xsl:template>
      <xsl:template match="/ns:SLA/ns:ServiceDefinition/ns:WSDLSOAPOperation/ns:SLAParameter/@name[.='TotalMemoryConsumption']">
            <xsl:attribute name='{name()}'>
                  <xsl:text>MemConsumption</xsl:text>
            </xsl:attribute>
      </xsl:template>
</xsl:stylesheet>

Where is the mistake?

EDIT: I want to parse this XML in Java with SAX, but I get the following error:

Element type "xsl:template" must be followed by either attribute specifications, ">" or "/>".

How to get rid of it?


Assuming you are actually trying to validate your XSL as an XML document, it looks like that website requires you to point to a schema or DTD in order to validate the XML against it. You can get a non-normative schema here: http://www.w3.org/TR/xslt20/#schema-for-xslt. Here's instructions on how to reference a schema from an XML file: http://www.ibm.com/developerworks/xml/library/x-tipsch.html

You could also check "Well-Formedness only," and check the document for well-formedness, if not actually validity.

Generally, any XSL engine will report any errors in your XSL document, so you don't need to validate it separately.


Your XSL is OK, don't worry. Just that there is no DTD/XSD for XSLs 1.0. no one bothers checking XSLT stylesheets (1.0) for validity. "Wellformedness" is enough.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜