我的 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: Element 'name' must have no element [children], and the value must be valid, line 6, XML Problem
另外:
cvc-pattern-valid: Value 'Arial-Functions' is not facet-valid with respect to pattern '($||\p{L})(\p{L}|\p{Nd}||$)*' for type 'null',line 6, XML Problem
XML 的第 6 行是:<name>Arial-Functions</name>
.
我做错了什么? PS:这在 TomEE Plus 和 Wildfly 8.x 上部署得很好
最佳答案
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 元素。
关于java - Eclipse (Kepler) 中的 Faces 配置架构验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22095828/