开发者

Why SAXParser doesn't like namespace in root element?

开发者 https://www.devze.com 2023-02-23 04:04 出处:网络
This is my XML: <?xml version=\"1.0\"?> <ui:composition xmlns=\"http://www.w3.org/1999/xhtml\"

This is my XML:

<?xml version="1.0"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html">
  <ui:define name="title">
    <h:outputText value="some t开发者_运维知识库ext"/>
  </ui:define>
</ui:composition>

This is what SAXParser from Xerces is saying:

Cannot find the declaration of element 'ui:composition'

What am I doing wrong?


Maybe you have XML Schema validation turned on, and the parser doesn't know where to find the XSD for the namespace?

What does the code look to parse the XML?


did you configure the saxparser to be namespace aware? (that is usually disabled by default). (you configured this on the SAXParserFactory before creating the SAXParser).


I predict that the real error message looks like:

SAXParseException:cvc - elt.1: Cannot find the declaration of element ...

and that would indicate that you turned on schema validation without enough schema.

0

精彩评论

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