简体   繁体   中英

cannot validate XML against XSD

I keep getting 2 errors trying to process my XML; says it's not a valid OAGIS doc. My XML is simple. The XSD is NotifyCatalog.xsd from OAGIS 9_6_1 When I use xmlvalidation.com it says:

Errors in the XML document: 2: 317 cvc-elt.1: Cannot find the declaration of element 'NotifyCatalog'.

Errors in file xml-schema: 27: 233 TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of ' http://www.openapplications.org/oagis/9 '.

Please help! XML below, XSD is >6000 lines, but I can attach if you like.

<?xml version="1.0" encoding="UTF-8"?>
<NotifyCatalog xmlns:xs="http://www.openapplications.org/oagis/9" targetNamespace:ibts="http://www.openapplications.org/oagis/9" versionID="9_4" releaseID="9_4" systemEnvironmentCode="Production">
  <ApplicationArea>
    <Sender>
      <LogicalID>MRP</LogicalID>
      <ComponentID>WID</ComponentID>
      <TaskID/>
      <ReferenceID>9990000000001568</ReferenceID>
      <ConfirmationCode>OnError</ConfirmationCode>
      <AuthorizationID>AUTOSYS</AuthorizationID>
    </Sender>
    <CreationDateTime>2017-03-21T15:10:08.551</CreationDateTime>
    <BODID>CATALOG-0000000000001</BODID>
  </ApplicationArea>
   <DataArea>
      <Notify>
         <ActionCriteria>
            <ActionExpression actionCode="Add">/NotifyCatalog/DataArea/Catalog/CatalogLine[Attachment/EmbeddedData=&apos;jimmy.pdf&apos;]</ActionExpression>/>
         </ActionCriteria>
      </Notify>
      <Catalog>
         <CatalogHeader>
            <DocumentID agencyRole="PLM">
               <ID/>
               <RevisionID/>
               <VariationID/>
            </DocumentID>
            <Description>HeaderPlasmaMonitorEBOM.pdf</Description>
         </CatalogHeader>
         <CatalogLine>
            <Item>
               <ItemID agencyRole="PLMDocument">
                  <ID>29433</ID>
                  <RevisionID>003</RevisionID>
               </ItemID>
                   <Description languageID="en-us">LinePlasmaMonitorEBOM.pdf</Description>
                   <Specification type="SecurityGroup">
                          <Property>
                             <NameValue name="SecurityGroup">PU</NameValue>
                          </Property>            
                   </Specification>
<!--                   <UserArea>                         <ibts:AttachmentUserArea/>                   </UserArea>-->
            </Item>
            <Attachment type="Thumbnail">
               <EmbeddedData mimeCode="normalizedString">jimmy.pdf</EmbeddedData>
            </Attachment>
         </CatalogLine>
      </Catalog>
   </DataArea>
</NotifyCatalog>

Haven't looked at the schema but unless it's a no-namespace schema (unlikely), you should begin your document like this:

<NotifyCatalog xmlns="http://www.openapplications.org/oagis/9"
               versionID="9_4"
               releaseID="9_4"
               systemEnvironmentCode="Production">
...

The xmlns= tells XML the default namespace to assign to elements that don't have a namespace prefix (none of the elements in your document have one, so all will receive the default namespace prefix).

This attribute specification:

targetNamespace:ibts="http://www.openapplications.org/oagis/9"

is bogus (and invalid since targetNamespace isn't a declared namespace prefix); if you wanted to specify ibts as namespace prefix binding, you must use

xmlns:ibts="http://www.openapplications.org/oagis/9"

but as said, you're not using ibts anywhere in the document so you can just remove the assignment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM