我在faces-config.xml
上声明了以下声明:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.1"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd">
<name>Arial-Functions</name>
</faces-config>
我遇到了以下Eclipse问题:
cvc-complex-type.2.2:元素'name'必须没有元素[children], 并且值必须有效,第6行,XML问题
此外:
cvc-pattern-valid:值'Arial-Functions'与facet无效 关于模式'($ | | \ p {L})(\ p {L} | \ p {Nd} | | $)*'的类型 'null',第6行,XML问题
XML的第6行是:<name>Arial-Functions</name>
。
我做错了什么? PS:这在TomEE Plus和Wildfly 8.x上很好地部署了
答案 0 :(得分:3)
web-facesconfig_2_1.xsd中 name 元素的定义:
<xsd:element name="name"
type="javaee:java-identifierType"
minOccurs="0"
maxOccurs="1">
javaee_5.xsd中 java-identifierType 的定义:
<xsd:complexType name="java-identifierType">
<xsd:annotation>
<xsd:documentation>
The java-identifierType defines a Java identifier.
The users of this type should further verify that
the content does not contain Java reserved keywords.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:restriction base="javaee:string">
<xsd:pattern value="($|_|\p{L})(\p{L}|\p{Nd}|_|$)*"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
Arial-Functions 不是有效的Java标识符。
您可以使用以下方式测试匹配项:
boolean match = "Arial-Functions".matches("($|_|\\p{L})(\\p{L}|\\p{Nd}|_|$)*");
System.out.println(match);
我希望JSF配置解析器不会针对架构验证XML,并且在任何情况下都会忽略 name 元素。