user function TXSchVld()
Local cXSD := "", cXML := ""
Local oXML
cXSD := '<?xml version="1.0"?>' + CRLF
cXSD += '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">' + CRLF
cXSD += '<xs:complexType name="bookInfo">' + CRLF
cXSD += ' <xs:sequence>' + CRLF
cXSD += ' <xs:element name="title" type="xs:string"/>' + CRLF
cXSD += ' <xs:element name="author" type="xs:string"/>' + CRLF
cXSD += ' <xs:element name="price" type="xs:decimal"/>' + CRLF
cXSD += ' </xs:sequence>' + CRLF
cXSD += '</xs:complexType>' + CRLF
cXSD += CRLF
cXSD += '<xs:element name="book" type="bookInfo"/>' + CRLF
cXSD += CRLF
cXSD += '</xs:schema>' + CRLF
oXML := TXMLManager():New()
// Vai exibir ".T."
conout( oXML:ParseSchema( cXSD ) )
// Com a linha "origin", que não está no schema declarado
cXML := '<book>' + CRLF
cXML += ' <title>A Clash of Kings</title>' + CRLF
cXML += ' <author>George R. R. Martin</author>' + CRLF
cXML += ' <price>9.99</price>' + CRLF
cXML += ' <origin>US</origin>' + CRLF
cXML += '</book>' + CRLF
// Vai exibir ".T."
conout( oXML:Parse( cXML ) )
// Vaiexibir ".F."
conout( oXML:SchemaValidate() )
// Agora sem a linha "origin", que não estava no schema
cXML := '<book>' + CRLF
cXML += ' <title >A Clash of Kings</title>' + CRLF
cXML += ' <author>George R. R. Martin</author>' + CRLF
cXML += ' <price>9.99</price>' + CRLF
cXML += '</book>' + CRLF
// Vai exibir ".T."
conout( oXML:Parse( cXML ) )
// Vaiexibir ".T."
conout( oXML:SchemaValidate() )
return
|