ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: [SEPA] fichier XSD   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

mer. 12 juin 2013, 20h33
Cesar Ch
Brésil Brésil

atoutfox.public.association

Re: [SEPA] fichier XSD

Salut Gregory,

I tried many hings here, still no success.
Please save the code below as a PRG, and run it, to see the problem I'm having:


The error is being raised when the line below is executed:
=m.schemaObj.ADD(m.nameSpace, m.xsdObj)


"OLE IDispatch exception code 0 from msxml6.dll: HeadCount.xsd#/HeadCount
Incorrect definition of the root element in the schema."


Thanks in advance!


CLEAR

LOCAL xmlFile, xsdFile
xmlFile = 'HeadCount.xml'
xsdFile = 'HeadCount.xsd'

TEXT TO lcHeadCount PRETEXT (1 + 2 + 4 + 8) NOSHOW
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<hc:HeadCount xmlns:hc='xsdHeadCount' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
 <Name Division='7'>Waldo Pepper</Name>
 <Name Division='88'>Red Pepper</Name>
</hc:HeadCount>
ENDTEXT
=STRTOFILE(m.lcHeadCount, xmlFile)

TEXT TO lcHeadCountXSD PRETEXT 15 NOSHOW
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<xs:schema xmlns="xsdHeadCount" targetNamespace="xsdHeadCount" xmlns:xs="http://www.w3.org/2001/XMLSchema";;>
 <xs:element name='HeadCount' type="HEADCOUNT"/>
 <xs:complexType name="HEADCOUNT">
 <xs:sequence>
 <xs:element name='Name' type='xs:string' maxOccurs='unbounded'/>
 </xs:sequence>
 <xs:attribute name='division' type='xs:int' use='optional' default='8'/>
 </xs:complexType>
</xs:schema>
ENDTEXT
=STRTOFILE(m.lcHeadCount, xsdFile)

LOCAL xsdObj, schemaObj, xmlObj

&& read schema
LOCAL xsdObj AS "Msxml2.DOMDocument.6.0"

xsdObj = CREATEOBJECT('Msxml2.DOMDocument.6.0')
xsdObj.ASYNC = .F.
xsdObj.ValidateOnParse = .T.

=m.xsdObj.LOAD( m.xsdFile)

schemaObj = CREATEOBJECT('Msxml2.XmlSchemaCache.6.0')
LOCAL nameSpace
* nameSpace = 'urn:xsdHeadCount'
* nameSpace = xsdObj.documentElement.getAttribute("targetNamespace")
nameSpace = 'xsdHeadCount'


=m.schemaObj.ADD(m.nameSpace, m.xsdObj)

xmlObj = CREATEOBJECT('Msxml2.DOMDocument.6.0')
xmlObj.ASYNC = .F.
xmlObj.ValidateOnParse = .F.

=xmlObj.setProperty('MultipleErrorMessages', .T.)
=m.xmlObj.LOAD(m.xmlFile)
xmlObj.Schemas = m.schemaObj


LOCAL parseError
parseError = m.xmlObj.VALIDATE()

IF( parseError.errorCode == 0 )
  ?'OK'
ELSE
  ? 'There are ', parseError.allErrors.LENGTH, ' parse errors'

  i = 0
  FOR i = 0 TO  parseError.allErrors.LENGTH-1
    ? REPLICATE('_', 50)
    errorObj= parseError.allErrors.ITEM(i)
    ? 'Error #', m.i+1

    ? 'error validating ', errorObj .errorCode
    ? 'error: ' , errorObj .errorCode
    ? 'reason:' , errorObj .reason
    ? 'source: ', errorObj .srcText
    ? 'location: ', errorObj .errorXPath
  ENDFOR
ENDIF

RETURN



Permalink : http://www.atoutfox.org/nntp.asp?ID=0000012107
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3