2014-01-06 2 views
0

나는이 XSD 조각이 유효한지 여부를 질문해야XSD 요소

<yolo /> 

감사

+0

@Digital_Reality, 이것은 귀하가 지적한 게시물과 중복되지 않습니다. –

답변

1

빠른 응답으로 스키마에 대한 XML 또는 XML로 스키마를 생성하는 온라인 도구를 사용하십시오, 스 니펫은 유효하지 않습니다. 당신이 시도 가정

<?xml version="1.0" encoding="utf-8" ?> 
<!-- XML Schema generated by QTAssistant/XSD Module (http://www.paschidev.com) --> 
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" xmlns="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <xsd:complexType name="test"> 
     <xsd:sequence> 
      <xsd:element name="yolo" minOccurs="0"/> 
      <xsd:element name="yolo" />   
     </xsd:sequence> 
    </xsd:complexType> 
</xsd:schema> 

:

의 당신이 (@Janty가 혼란있어 이후, 분명히 같은 깊이 무엇을 의미합니까 만들기 위해) 다음과 같은 맥락에서 위의 코드를 넣어한다고 가정 해 봅시다 닷넷 XSD 프로세서 이상, 다음과 같은 오류 얻을 것 ...

Multiple definition of element ' http://tempuri.org/XMLSchema.xsd:yolo ' causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.

당신은 Xerces를 기반 프로세서를 시도 할 경우를

cos-nonambig: " http://tempuri.org/XMLSchema.xsd ":yolo and " http://tempuri.org/XMLSchema.xsd ":yolo (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.

XSD 사양에는 cos-nonambig here (다소간의 Microsoft 구현 오류 메시지)이 설명되어 있습니다.

그러나 혼란을 줄이기 위해 일부 프로세서에서는 UPA 동작을 (구체적으로 또는 간접적으로) 재정의 할 수 있으므로 동일하게 시도하고 오류가 발생하지 않을 수도 있습니다 ... Microsoft는 EnableUpaCheck 및 Xerces에는 schema-full-checking 기능이 포함되어 있습니다.

Microsoft 문서가 귀하의 케이스에 적용됩니다 ... 이것이 그들의 예입니다 ... 일치하는가요?

<xs:sequence> 
    <xs:element name="A" type="xs:string"/> 
    <xs:element name="B" type="xs:string" minOccurs="0"/> 
    <xs:element name="B" type="xs:string"/> 
</xs:sequence> 
+0

나에게 많은 도움이 된 매우 자세한 설명. 고맙습니다! –

0

<yolo />

들어

아래 스키마가 있어야합니다.

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="yolo" type="xs:string"/> 
</xs:schema> 

XSD2XMLXML2XSD

+0

감사합니다. 그러나 제공된 XML 예제를 대신하여 내 XSD를 작성하고 싶지 않습니다. XSD의 유효성을 검사 할 수있는 도구를 작성 중입니다. 도구에서 위의 XSD를 얻으면 유효하다고 생각합니까? 이 예제에서는 "더 나은"XSD를 작성할 수 있음을 알고 있습니다. 그러나 그것은 나의 요점이 아니다. 덕분에 –

+0

좋습니다. 그러면 xsd 개발 http://www.w3schools.com/schema/schema_example.asp의 기본을 살펴보아야합니다. 올바른 스키마를 작성하는 데 도움이됩니다. – Janty