You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Groeger, Olaf" <OG...@heiler.com> on 2001/10/18 15:05:45 UTC

xml4com and wsh

Hi, i'm a newbie on xerces, but very interested in the com wrapper. i
made some experiments with it and found out that it is problematic to
use with vbscript in that away, that it rejects byref parameters.
for instance:

dim strXML
strXML = "test.xml"

dim xmlDoc
set xmlDoc = CreateObject( "Xerces.DOMDocument" )

if xmlDoc.load( strXML ) then
...
end if

This fails for Xerces because strXML is passed as VT_VARIANT|VT_BYREF
and not as VT_BSTR. To make it running it must be ensured to pass the
parameters ByValue, for instance:

if xmlDoc( ( strXML ) ) then ...
or
if xmlDoc( CStr( strXML ) ) then ...

This behaviour makes it impossible to simply replace MSXML by Xerces. So
my question is: Shouldn't we enhance the com wrapper to accept
VT_VARIANT|BYREF arguments ? to the load function, for instance, could
be added something like:

  if( V_VT( &xmlSource ) == ( VT_VARIANT | VT_BYREF ) )
  {
    variant_t vtString( &xmlSource );
    m_FileName = vtString.operator _bstr_t();

    if( 0 == m_FileName.length() )
      return E_INVALIDARG;

    // see if the file is relative path
		if (!PathIsURL(m_FileName) &&
PathIsRelative(m_FileName)) {
			// try appending baseurl if exists
			_bstr_t baseURL;
			if (S_OK == GetBaseURL(baseURL)) {
				// change any backslashes to slashes
				LPTSTR loc =
_tcschr(m_FileName,_T('\\'));
				while (loc != NULL) {
					*loc = _T('/');
					loc =
_tcschr(m_FileName,_T('\\'));
				}
				m_FileName = baseURL + _T("/") +
m_FileName;
			}
		}

  }

Another question i have is why the resolveExternals property is
disabled. As far as i can see in the DOMCount project, Xerces should
support this feature.

Regards,

Dr. Olaf Groeger


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: xml4com and wsh

Posted by Curt Arnold <ca...@houston.rr.com>.
> This behaviour makes it impossible to simply replace MSXML by Xerces.

Actually, that usage is pretty unusual and most MSXML calling VB code
doesn't run into the problem.  If you had dim'd strXML as String instead of
Variant it would have worked.  You are right that there should be a call to
VariantChangeType to coerce the argument to VT_BSTR within the
implementation.

>Another question i have is why the resolveExternals property is
>disabled. As far as i can see in the DOMCount project, Xerces should
>support this feature.

Will have to look at that over the weekend and I'll submit a patch for the
problem you mentioned.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org