2016-12-16 6 views
0

ををxsdに対応:xmlファイル誰もが与えられたライン上のXMLファイルを作成する際に私を助けることができる私は、XMLの検証に新しいです

<?xml version="1.0" encoding="UTF-8"?> 
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://logging.apache.org/log4j/2.0/config" 
    xsi:schemaLocation="http://logging.apache.org/log4j/2.0/config log4j.xsd"> 

    <Appenders> 
     <Console name="JCATDefaultConsoleAppender" target="SYSTEM_OUT" 
      follow="true"> 
      <PatternLayout pattern="%d{default} %m [%t] %l%n%ex{full}" /> 
     </Console> 
    </Appenders> 

    <Loggers> 
     <Root level="INFO"> 
      <AppenderRef ref="JCATDefaultConsoleAppender" /> 
     </Root> 
    </Loggers> 
</Configuration> 

私のXSDは、次のようになります。私は取得しています

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE file distributed with 
this work for additional information regarding copyright ownership. 
The ASF licenses this file to You under the Apache License, Version 2.0 
(the "License"); you may not use this file except in compliance with 
the License. You may obtain a copy of the License at 
     http://www.apache.org/licenses/LICENSE-2.0 
Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. 
--> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns="http://logging.apache.org/log4j/2.0/config" 
    elementFormDefault="qualified" targetNamespace="http://logging.apache.org/log4j/2.0/config"> 
    <xs:element name="Configuration" type="ConfigurationType"/> 
    <xs:complexType name="ConfigurationType"> 
     <xs:sequence> 
      <xs:choice minOccurs="0" maxOccurs="1"> 
       <xs:element name="CustomLevels" type="CustomLevelsType"/> 
       <xs:element name="CustomLevel" type="CustomLevelType"/> 
      </xs:choice> 
      <xs:element name="Properties" type="PropertiesType"/> 
      <xs:choice minOccurs="0" maxOccurs="1"> 
       <xs:element name="Filters" type="FiltersType"/> 
       <xs:element name="Filter" type="FilterType"/> 
      </xs:choice> 
      <xs:element name="ThresholdFilter" type="ThresholdFilterType"/> 
      <xs:element name="Appenders" type="AppendersType"/> 
      <xs:element name="Loggers" type="LoggersType"/> 
     </xs:sequence> 
     <xs:attribute name="packages" type="xs:string"/> 
     <xs:attribute name="status" type="xs:string"/> 
     <xs:attribute name="strict" type="xs:string"/> 
     <xs:attribute name="name" type="xs:string"/> 
     <xs:attribute name="advertiser" type="xs:string"/> 
     <xs:attribute name="schema" type="xs:string"/> 
    </xs:complexType> 
    <xs:complexType name="PropertiesType"> 
     <xs:sequence> 
      <xs:element name="Property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="AppenderType"> 
     <xs:sequence> 
      <xs:element name="Layout" type="LayoutType" minOccurs="0"/> 
      <xs:choice minOccurs="0" maxOccurs="1"> 
       <xs:element name="Filters" type="FiltersType"/> 
       <xs:element name="Filter" type="FilterType"/> 
      </xs:choice> 
     </xs:sequence> 
     <xs:attribute name="type" type="xs:string" use="required"/> 
     <xs:attribute name="name" type="xs:string" use="required"/> 
     <xs:attribute name="fileName" type="xs:string" use="optional"/> 
    </xs:complexType> 
    <xs:complexType name="RootType"> 
     <xs:sequence> 
      <xs:element name="AppenderRef" type="AppenderRefType" minOccurs="1" maxOccurs="unbounded"/> 
     </xs:sequence> 
     <xs:attribute name="level" type="xs:string"/> 
    </xs:complexType> 
    <xs:complexType name="PropertyType"> 
     <xs:simpleContent> 
      <xs:extension base="xs:string"> 
       <xs:attribute name="name" type="xs:string"/> 
      </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
    <xs:complexType name="KeyValuePairType"> 
     <xs:simpleContent> 
      <xs:extension base="xs:string"> 
       <xs:attribute name="key" type="xs:string"/> 
       <xs:attribute name="value" type="xs:string"/> 
      </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
    <xs:complexType name="AppendersType"> 
     <xs:sequence> 
      <xs:element name="Appender" type="AppenderType" minOccurs="1" maxOccurs="unbounded"/> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="AppenderRefType"> 
     <xs:simpleContent> 
      <xs:extension base="xs:string"> 
       <xs:attribute name="ref" type="xs:string" use="required"/> 
      </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
    <xs:complexType name="LoggerType"> 
     <xs:sequence> 
      <xs:choice minOccurs="0" maxOccurs="1"> 
       <xs:element name="Filters" type="FiltersType"/> 
       <xs:element name="Filter" type="FilterType"/> 
      </xs:choice> 
      <xs:element name="AppenderRef" type="AppenderRefType"/> 
     </xs:sequence> 
     <xs:attribute name="name" type="xs:string" use="required"/> 
     <xs:attribute name="level" type="xs:string" use="optional"/> 
     <xs:attribute name="additivity" type="xs:string" use="optional"/> 
    </xs:complexType> 
    <xs:complexType name="FilterType" mixed="true"> 
     <xs:sequence> 
      <xs:element name="KeyValuePair" type="KeyValuePairType" minOccurs="0"/> 
     </xs:sequence> 
     <xs:attribute name="type" type="xs:string" use="required"/> 
     <xs:attribute name="level" type="xs:string" use="optional"/> 
     <xs:attribute name="marker" type="xs:string" use="optional"/> 
     <xs:attribute name="onMatch" type="xs:string" use="optional"/> 
     <xs:attribute name="onMismatch" type="xs:string" use="optional"/> 
    </xs:complexType> 
    <xs:complexType name="FiltersType"> 
     <xs:sequence> 
      <xs:element name="Filter" type="FilterType" minOccurs="0" maxOccurs="unbounded"/> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="CustomLevelType"> 
     <xs:attribute name="name" type="xs:string" use="required"/> 
     <xs:attribute name="intLevel" type="xs:string" use="required"/> 
    </xs:complexType> 
    <xs:complexType name="CustomLevelsType"> 
     <xs:sequence> 
      <xs:element name="CustomLevel" type="CustomLevelType" minOccurs="0" maxOccurs="unbounded"/> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="LoggersType" mixed="true"> 
     <xs:sequence> 
      <xs:element name="Logger" type="LoggerType" minOccurs="0" maxOccurs="unbounded"/> 
      <xs:element name="Root" type="RootType" minOccurs="1" maxOccurs="1"/> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="LayoutType" mixed="true"> 
     <xs:sequence> 
      <xs:element name="Pattern" type="xs:string" minOccurs="0"/> 
     </xs:sequence> 
     <xs:attribute name="type" type="xs:string" use="required"/> 
     <xs:attribute name="pattern" type="xs:string" use="optional"/> 
    </xs:complexType> 
    <xs:complexType name="ThresholdFilterType"> 
     <xs:attribute name="level" type="xs:string" use="optional"/> 
     <xs:attribute name="onMatch" type="xs:string" use="optional"/> 
     <xs:attribute name="onMismatch" type="xs:string" use="optional"/> 
    </xs:complexType> 
</xs:schema> 

エラー次のとおりです。

[ERROR]はゴールse.ericsson.jcat.ebs実行に失敗しました

:プロジェクトEBS-拡張に検証(デフォルト):XML-検証 - プラグイン:1.0.2メートルを実行できませんojo:/home/xchoshu/latestWorkspace/ebs-extensions/src/main/resources/log4j2.xmlを構文解析するときは、ファイル:/home/xchoshu/latestWorkspace/ebs-extensions/src/main/resources/log4j2.xmlにあります。 6、列16:cvc-complex-type.2.4.a:要素 'Appenders'で始まる無効なコンテンツが見つかりました。 '{"http://logging.apache.org/log4j/2.0/config":CustomLevels、 "http://logging.apache.org/log4j/2.0/config":プロパティ}のいずれかが必要です。 - > [ヘルプ1]

誰かが私のXMLを変更してXMLの検証に合格すると感謝します。

TIA

+0

既に回答済みhttp://stackoverflow.com/questions/41177776/xsd-validation-is-failing – Sprotty

答えて

0

<xs:complexType name="ConfigurationType">定義を読むことによって、<Configuration>タグは子タグ(この順序で)として表示する必要があり、あなたが提供されたスキーマを見て:

  1. オプションCustomLevelsまたはCustomLevelタグ;
  2. 必須Propertiesタグ;
  3. 任意FilterまたはFiltersタグ;
  4. 必須ThresholdFilterタグ;
  5. 必須Appendersタグ;
  6. 必須Loggersタグ。
関連する問題