Share via


Testing Your Schema

Topic Last Modified: 2006-06-12

Note

To access the global schema of an application or a public store, use The ##SCHEMAURI## Macro.

Example

VBScript

<job id="testschema">
<reference object="adodb.record"/>
<script language="vbscript">

Dim InfoNT
Dim Conn
Dim Rec
Dim Rs
Dim strQ
Dim strURL
Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "ExOLEDB.DataSource"

Set Rs = CreateObject("ADODB.Recordset")
Set Rec = CreateObject("ADODB.Record")
Set InfoNT = CreateObject("WinNTSystemInfo")

strURL = "http://" & InfoNT.ComputerName & "/public/test_folder/"
Conn.Open strURL

Rec.Open strURL, Conn, adModeReadWrite
Rec.Fields("urn:schemas-microsoft-com:exch-data:schema-collection-ref") = strUrl & "schema"
Rec.Fields("urn:schemas-microsoft-com:exch-data:expected-content-class") = _
   Array("urn:schemas-domain-tld:content-classes:recipe")
Rec.Fields.Update
Rec.Close

Rec.Open strURL & "schema", Conn, adModeReadWrite
Rec.Fields("urn:schemas-microsoft-com:exch-data:baseschema") = Array(CStr("/public/non_ipm_subtree/Schema"))
Rec.Fields.Update
Rec.Close

Rec.Open strURL & "test1.txt", Conn, adModeReadWrite, adCreateNonCollection
Rec.Fields("urn:schemas-domain-tld:title").Value      = "Title Here"
Rec.Fields("urn:schemas-domain-tld:submitdate").Value       = Now
Rec.Fields("urn:schemas-domain-tld:rating").Value           = CLng(4)
Rec.Fields("urn:schemas-domain-tld:cuisine").Value      = CStr("Cuisine Here")
Rec.Fields("urn:schemas-domain-tld:ingredients").Value  = Array("this", "that", "something-else")
Rec.Fields("urn:schemas-domain-tld:instructions").Value = CStr("The instructions here.")
Rec.Fields("DAV:contentclass") = "urn:schemas-domain-tld:content-classes:recipe"
Rec.Fields.Update
Rec.Close

Rec.Open strURL & "test1.txt", Conn
For Each Fld in Rec.Fields
 wscript.echo Fld.Name
 if not isarray(fld.value) then
   wscript.echo fld.value
 end if

wscript.quit

strQ = "SELECT * from scope('shallow traversal of "
strQ = strQ & Chr(34) & strURL & Chr(34) & "') WHERE ""DAV:isfolder"" = False AND ""DAV:ishidden"" = False"

Rs.Open strQ, Conn
Rs.MoveFirst
Do Until Rs.EOF
   For x = 0 To Rs.Fields.Count - 1
      Wscript.Echo "Name: " & Rs(x).Name
      If VarType(Rs(x).Value) = vbString _
                  Or VarType(Rs(x).Value) = vbInteger _
                    Or VarType(Rs(x).Value) = vbLong _
                     Or VarType(Rs(x).Value) = vbDate Then
         Wscript.Echo "Value: " & Rs(x).Value
                Else
                  wscript.echo vartype(Rs(x).Value)
                End If
   Wscript.Echo "Next Record-----------------------"
   Rs.MoveNext
Loop

Rs.Close
</script>
</job>