2009-09-05 2 views
1

이 XML이 유효하지 않다고 느끼고 있습니다. 이유를 설명해주세요.유효한 XML입니까?

나는 이것에 요소 이름으로 도트가 될 것이라고 생각합니까?

estate_price.price_suggestion

이 XML에 대해 다른 어떤 것이 유효하지 않습니까?

XML

좋은 XML 문서의 두 가지 수준이 있습니다
\\ <?xml version="1.0" encoding="UTF-8"?> 

<iad> 
    <DataTag> 
    <element id="0"> 
     <changed_string>content</changed_string> 
     <no_of_bedrooms>content</no_of_bedrooms> 
     <published_string>content</published_string> 
     <mmo>content</mmo> 
     <postcode>content</postcode> 
     <utmx>content</utmx> 
     <utmy>content</utmy> 
     <disposed>content</disposed> 
     <property_type>content</property_type> 
     <isprivate>content</isprivate> 
     <heading>content</heading> 
     <published>content</published> 
     <estate_price.price_suggestion>content</estate_price.price_suggestion> 
     <ownership_type>content</ownership_type> 
     <estate_size.useable_area>content</estate_size.useable_area> 
     <adid>content</adid> 
     <address>content</address> 
     <sqmtrprice>content</sqmtrprice> 
     <estate_size.primary_room_area>content</estate_size.primary_room_area> 
     <location>content</location> 
     <changed>content</changed> 
     <orgname>content</orgname> 
    </element> 
    <element id="1"> 
     <changed_string>content</changed_string> 
     <no_of_bedrooms>content</no_of_bedrooms> 
     <published_string>content</published_string> 
     <mmo>content</mmo> 
     <postcode>content</postcode> 
     <utmx>content</utmx> 
     <utmy>content</utmy> 
     <disposed>content</disposed> 
     <property_type>content</property_type> 
     <isprivate>content</isprivate> 
     <heading>content</heading> 
     <published>content</published> 
     <estate_price.price_suggestion>content</estate_price.price_suggestion> 
     <ownership_type>content</ownership_type> 
     <estate_size.useable_area>content</estate_size.useable_area> 
     <adid>content</adid> 
     <address>content</address> 
     <sqmtrprice>content</sqmtrprice> 
     <estate_size.primary_room_area>content</estate_size.primary_room_area> 
     <location>content</location> 
     <changed>content</changed> 
     <orgname>content</orgname> 
    </element> 
    </DataTag> 
</iad> 

답변

2

귀하의 문서가 유효한지 여부를 확인하기 위해 유효성을 검사하는 스키마가 필요합니다.

estate_price.price_suggestion은 XML 사양에 의해 금지 된 요소 이름으로는 존재하지 않지만 스키마는 해당 요소 (또는 다른 요소)를 허용하지 않는 문서 콘텐츠 및 구조에 대한 제약 조건을 배치 할 수 있습니다. 그것이있는 곳에 배치하십시오.

6

: well-formed 유효한. 올바른 형식은 XML 표준을 따르고 스키마를 준수 함을 의미합니다.

스키마는 사용중인 요소 및 다른 요소 내부로 이동할 수있는 사양을 나타냅니다. DTD, XSD (W3C Schema), Relax NG 등을 사용하여 스키마를 지정할 수 있습니다.

1

Dave Markle은 XML 프롤로그에 백 슬래시 접두어가 없어야한다는 점에서 정확합니다 (또한 기본 프롤로그 값만 제공하므로 선택 사항입니다).

요소 이름의 점에 대해서는 to the XML spec for start tags으로 가면 NameStartChar와 NameChar 시퀀스로 이루어진 Name이 포함되어 있음을 알 수 있습니다. NameChar 세트는 "."문자를 포함하므로, 첫 번째 문자가 아닌 한 태그 이름에 .을 사용하는 것이 완전히 유효합니다.

0

XML이 올바른 형식이며 유효성을 검사하지 않는 XML 구문 분석기에서 구문 분석해야합니다. 예를 들어 나는

 try { 
     new nu.xom.Builder().build(new StringReader(s)); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    System.out.println("OK"); 

그러나 속성의 유형에 대한 가정을 일부 XML 도구가 있습니다 (http://www.xom.nu에서) XOM을 사용하고 있습니다. id 속성은 ID 유형으로 가정 할 수 있습니다. 이 유형은 id 값을 _A-Za-z ('0-9', '-'또는 '.'가 아님)로만 시작할 수있는 유효한 XML 이름으로 제한합니다. 따라서 XML이 잘 형성되었지만 ID에 숫자를 사용하는 것은 좋지 않을 수 있습니다. 이미 지적했듯이 DTD 또는 스키마가있는 경우 ID가 유효성 검증 실패의 원인이되는 유형 ID가되도록 강요되었을 수 있습니다.

귀하의 게시물에서 이미 문제가 있었는지 확실하지 않습니다. 오류 메시지를 게시하면 도움이 될 수 있습니다.