java - Eclipse (Kepler) 中的 Faces 配置架构验证问题

标签 java eclipse jsf-2

我的 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.xsdname 元素的定义:

<xsd:element name="name"
  type="javaee:java-identifierType"
  minOccurs="0"
  maxOccurs="1">

javaee_5.xsdjava-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/

相关文章:

java - Ganib (Java) - 无法发送验证邮件

java - Eclipse Juno jar android 依赖问题

eclipse - 在 PyDev + Eclipse 中运行当前项目中的所有单元测试的键盘快捷键是什么?

validation - 我可以使用 JSF 标记中指定的选项制作 JSF 验证器吗?

jsf - JSF 1.2和JSF 2.x之间的JSTL xmlns namespace 差异?

java - JTable 不想显示内容

java - 如何在 MappingJackson2MessageConverter 中设置 typeIdPropertyName

java - 两种远程调试方式

jsf - 用于链接/导航到其他 JSF 页面的 URL

java - TabbedPaneUI 绘制选定的选项卡