xsd - What is wrong with my XML? -


can please me below xml?

<?xml version="1.0" encoding="utf-8" ?> <xs:collection-list xmlns:xs="http://www.hp.com/hpsim7.5.0.0"                      elementformdefault="qualified">       <xs:collection name="abc"                   type="system"                   parent="systems type">     <member name="all servers"              type="query"              display-status="0"default-view="tableview"              hidden="false" />   </collection> </collection-list> 

i not sure what's wrong it.

what's wrong xml is not well-formed.

that is, not meet basic requirements being xml. then, per comment error indicating collection-list cannot found, xml not valid. is, not meet additional requirements specified schema. might want read more well-formed vs valid xml in general.

below, each category of problems in particular case. use xerces-j error message concrete, similar errors issued conformant xml parser.

well-formed

[fatal error] try.xml:9:31: element type "member" must followed either attribute specifications, ">" or "/>".

  • explanation: parser cannot complete processing of member, indicating problem while parsing attributes (before getting end of opening tag marked > or />.
  • resolution: add whitespace before default-view="tableview" attribute.

[fatal error] try.xml:12:5: element type "xs:collection" must terminated matching end-tag "</xs:collection>".

  • explanation: parser sees no closing </xs:collection> because namespace prefix missing on </collection>.
  • resolution: add namespace prefix closing collection tag.

repeat collection-list.

other notes:

  • i reserve xs namespace prefix xml schema elements (although isn't strictly necessary).
  • i remove elementformdefault attribute hp:collection-list looks mistakenly has been copied on xsd.
  • i'll assume member element intended in http://www.hp.com/hpsim7.5.0.0 namespace simplify demonstrating xsd xml in next section.

altogether, then, here text turned well-formed xml:

<?xml version="1.0" encoding="utf-8" ?> <hp:collection-list xmlns:hp="http://www.hp.com/hpsim7.5.0.0">       <hp:collection name="abc"                   type="system"                   parent="systems type">     <hp:member name="all servers"                 type="query"                 display-status="0"                default-view="tableview"                 hidden="false"/>   </hp:collection> </hp:collection-list> 

valid

now have well-formed xml, can proceed attempt validate it, when do, you'll encounter error:

[error] try.xml:3:52: cvc-elt.1.a: cannot find declaration of element 'hp:collection-list'.

  • explanation: parser cannot find xsd elements in file, starting root element, hp:collection-list.
  • resolution: hint parser xsd using xsi:schemalocation, value consists of namespace-location pairs, separated spaces.

here xml xsi:schemalocation hinting xsd location:

<?xml version="1.0" encoding="utf-8" ?> <hp:collection-list xmlns:hp="http://www.hp.com/hpsim7.5.0.0"                      xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"                     xsi:schemalocation="http://www.hp.com/hpsim7.5.0.0 try.xsd">       <hp:collection name="abc"                   type="system"                   parent="systems type">     <hp:member name="all servers"                 type="query"                 display-status="0"                default-view="tableview"                 hidden="false" />   </hp:collection> </hp:collection-list> 

and here xsd validates above xml:

<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"            targetnamespace="http://www.hp.com/hpsim7.5.0.0">   <xs:element name="collection-list">     <xs:complextype>       <xs:sequence>         <xs:element name="collection" maxoccurs="unbounded">           <xs:complextype>             <xs:sequence>               <xs:element name="member">                 <xs:complextype>                   <xs:sequence/>                   <xs:attribute name="name"/>                   <xs:attribute name="type"/>                   <xs:attribute name="display-status" type="xs:integer"/>                   <xs:attribute name="default-view"/>                   <xs:attribute name="hidden" type="xs:boolean"/>                 </xs:complextype>               </xs:element>             </xs:sequence>             <xs:attribute name="name"/>             <xs:attribute name="type"/>             <xs:attribute name="parent"/>           </xs:complextype>         </xs:element>       </xs:sequence>     </xs:complextype>   </xs:element> </xs:schema> 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -