- From: McDonald, Tom [EESUS, Non J&J] <TMcDona@EESUS.JNJ.com>
- Date: Tue, 22 Jan 2002 12:00:30 -0500 (EST)
- To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
- Message-ID: <B62C798CD6ECD511BE8300805F85AE9844FC05@eesusciexs4.eesus.jnj.com>
I thought you might be interested in actually seeing the code that I am
trying to debug.
Here is the schema and the code is below. Note that I am using ASP code.
--schema--------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="plyrid" type="xs:short"/>
<xs:element name="projectedScore" type="xs:decimal"/>
<xs:element name="projection">
<xs:complexType>
<xs:sequence>
<xs:element ref="plyrid"/>
<xs:element ref="projectedScore"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="projectionInfo">
<xs:complexType>
<xs:sequence>
<xs:element ref="projection"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="user_number" type="xs:short"/>
<xs:element name="editplayer">
<xs:complexType>
<xs:sequence>
<xs:element ref="user_number"/>
<xs:element ref="projectionInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
---------------------------------
--code------------------------
<%
set xmlDoc = Server.CreateObject("MSXML2.DOMDocument.4.0")
sSchema = "editplayer.xsd"
sSchemaDef = ""
sSchemaPath = "http://localhost/tomandlis/stage1/schema/"
sSchemaLoc = sSchemaPath & sSchema
Dim xmlDoc1
Set xmlDoc1 = Server.CreateObject("MSXML2.DOMDocument.4.0")
xmlDoc1.async = false
xmlDoc1.setProperty "ServerHTTPRequest", true
if not xmlDoc1.load(sSchemaLoc) then
response.write xmlDoc1.parseError.reason + " Error Element="
+ xmlDoc1.parseError.srcText
Set xmlDoc1 = Nothing
response.end
end if
Set xSchemaCache = server.createobject("MSXML2.XMLSchemaCache.4.0")
xSchemaCache.Add sSchemaDef, xmlDoc1
' add the schemas to the domdocument
Set xmlDoc.schemas = xSchemaCache
'generate a sample xml doc for testing
sxml =
"<editplayer><user_number>721</user_number><projectionInfo><projection><plyr
id>1036</plyrid><projectedScore>99ab</projectedScore></projection></projecti
onInfo></editplayer>"
xmlDoc.async = False
xmlDoc.validateOnParse = False
'Get the xml doc instance location/name
'If load fails raise an error
If Not xmlDoc.loadXML(sxml) Then
response.write xmlDoc.parseError.reason + " Error Element="
+ xmlDoc.parseError.srcText
Set xmlDoc = Nothing
Set xSchemaCache = Nothing
response.end
Else
'TRY AND VALIDATE!!
boo = xmlDoc.Validate()
If boo Then
response.write "Document is valid"
Else
response.write "Validation error:" +
xmlDoc.parseError.reason
End If
End If
response.write xmldoc.xml
Set xmlDoc = Nothing
Set xSchemaCache = Nothing
%>
---------------------------------
Received on Wednesday, 23 January 2002 13:41:21 UTC