Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 24 JAN 2008 05:42:27AM Dale Jessop wrote:

Does anyone know how to retrieve using OI the data type in an XML schema object or SOM using the getDeclaration method?

from this xml schema I want to retrieve the xs:string value using the getDeclaration method but cannot seem to do it.


At 25 JAN 2008 02:24PM Warren Auyong wrote:

I can't get this to work either. The VB example shows:

Set oDecl=oDoc.namespaces.getDeclaration(oDoc.documentElement)

MsgBox oDecl.namespaceURI

Which in Basic+ I tried:

oDoc=OleCreateInstance("Msxml2.DOMDocument.6.0")

oDoc-]ResolveExternals=True

oDoc-]async=False

oDoc-]ValidateOnParse=True

* load the XML and XSD into cache as in my previous example

oDocNS=oDoc-]namespaces

oDocElement=oDoc-]documentElement

oDecl=OleCallMethod(oDocNS,'getDeclaration',oDocElement)

is_ok=(OleStatus()=0)

msgbox=oDecl-]namespaceURI

is_ok returns 0

Perhaps one of the other VB to Basic+ wiz kids can tell us what I'm doing wrong.

The "Walk the SOM" example will work when converted to BASIC+. I don't know if that will help in what you're trying to do though.

http://msdn2.microsoft.com/en-us/library/ms760252%28VS.85%29.aspx


At 25 JAN 2008 08:12PM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

Warren,

From what I can determine the only way the getDeclaration() method works is with a v4 DOM document - it fails with a v6.

This is from the example on MSDN:

pre.code {

 background-color: #E5E5E5;
 border: 1px solid #000000;
 width: 940px;
 padding: 5px;
 font-family: courier, verdana, arial, serif;
 margin: 0px 10px auto;

}


compile subroutine cp_test_another_xsd( void )
/*
   From the MS getDeclaration examples on MSDN

   doc.xml:
  
   <?xml version=1.0"?>
   <x:doc  xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance'
       xmlns:x=http://xsdtesting'
       xsi:schemaLocation=http://xsdtesting doc.xsd'>
       <x:notDeclared/>
   </x:doc>

   ////////////////////////////////////////////////////////////////////
  
   doc.xsd
  
   <?xml version=1.0"?>
   <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema"
      targetNamespace=http://xsdtesting"
      xmlns:x=http://xsdtesting"
      elementFormDefault=qualified">
      <xs:element></xs:element>
   </xs:schema>
  
   ////////////////////////////////////////////////////////////////////
  
   doc.js

   var xmldoc=new ActiveXObject("MSXML2.DOMDocument.4.0");
   xmldoc.async=false;
   xmldoc.validateOnParse=false;
   xmldoc.load("doc.xml");
   xmldoc.setProperty("SelectionLanguage", "XPath");

   if (xmldoc.parseError.errorCode != 0){
      var myErr=xmldoc.parseError;
      WScript.Echo("You have error " & myErr.reason);
   } else {
      // Retrieve the namespace URI for schema
      // used in XML document.
      var oDecl=xmldoc.namespaces.getDeclaration(xmldoc.documentElement);
      WScript.Echo(oDecl.namespaceURI);
   }

*/
   xmlFile=C:\Revsoft\Clients\3M\XSD\doc.xml"
   xsdFile=C:\Revsoft\Clients\3M\XSD\doc.xsd"
  
   objDoc=OleCreateInstance( 'msxml2.DOMDocument.4.0' )
   objDoc ->Async=0
   objDoc ->ValidateOnParse=0
  
   x=objDoc->Load( xmlFile )
   x=objDoc->SetProperty( "SelectionLanguage", "XPath" )

   objNode=objDoc->documentElement
   objNS  =objDoc->namespaces
  
   objDec=objNS->getDeclaration( objNode )
  
   type  =objDec->itemType 
  
   debug
  
return

The Sprezzatura Group

World leaders in all things RevSoft


At 25 JAN 2008 09:15PM Warren Auyong wrote:

Thanks! At least I still have a few hairs left on my head.

MSFT removed XDR support in 6.0 but according to the version matrix getDeclaration is still supported. I ran across somewhere that there was a difference in how Namespaces were handled in 6.0 getDeclaration. Ha! Another undocumented feature I ran across on one forum is that in 6.0 you need to set the resolveExternals property to true for most of the schema functions to work in the first place unless using an inline schema.

4.0 has issues that it doesn't appear to support some schema features.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/553fc4c882af6dc1852573da003ad191.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1