RE: [xsl] pattern matching possible?

Subject: RE: [xsl] pattern matching possible?
From: "Hardy Merrill" <HMerrill@xxxxxxxxxxxxxxxx>
Date: Thu, 13 May 2004 09:40:33 -0400
John, this is the CreateObject statement we're using:

  Set oXml = Server.CreateObject("MsXml2.FreeThreadedDOMDocument.4.0"
)

and the msxml file we installed is  msxml4.exe which was downloaded
from Microsoft.  So aren't we using MSXML4?  Just to re-iterate, our
translate statement didn't work until we added the

   oXML.setProperty "SelectionLanguage", "XPath"

We needed to use the FreeThreadedDOMDocument.4.0 because we store that
DOM object in a session variable.   I see that we are using a different
CreateObject parameter than you specified("Msxml2.DOMDocument.4.0"), but
I'm not sure just what that means and what the difference is.  I'm an
XSL newbie so I'm just trying to understand what's happening and why.

Hardy Merrill

>>> John.Hansen@xxxxxxxxxx 05/13/04 09:23AM >>>
While you might think you are using MSXML4 you can't actually be using
it if you get an error when using translate because DOMDocument40 sets
the SelectionLanguage second level property to XPath *by default* and
you can't actually select another language (it doesn't support the old
selection language).

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/

htm/xml2nd_pro_v4_9rc5.asp

<quote>
In MSXML 3.0 you can set this property to "XPath" to switch the query
language from XSLPattern to XPath. After the property is set, there is
no way to switch back without creating an instance of a new DOM object.


MSXML 4.0 and later supports XPath as the only query language. This
property is always set to "XPath" in MSXML 4.0 and later. You can
ignore
this property completely.
</quote>

On the page you reference below it says:

'To use MSXML 4.0, you need to use 4.0 dependent progid explicitly.

Which means you need to 

set oXML = Server.CreateObject("Msxml2.DOMDocument.4.0"); 

Rather than

set oXML = Server.CreateObject("Msxml2.DOMDocument"); 

Again, if you really are using MSXML4 then there is no need to set the
selection language to XPath.

-----Original Message-----
From: Hardy Merrill [mailto:HMerrill@xxxxxxxxxxxxxxxx] 
Sent: Thursday, May 13, 2004 8:01 AM
To: Hansen, John; xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
Subject: RE: [xsl] pattern matching possible?


A co-worker of mine found the answer this morning on MS support site:

   http://support.microsoft.com/default.aspx?scid=kb;en-us;315719 

Note that we *are* using MSXML 4.

Here's a snipped from that page:

SUMMARY
MSXML includes two functions that you can use to filter data in a
case-insensitive search. With MSXML 3.0, you can use the translate
function. With MSXML 4.0, you can use either the translate function or
the new ms:string-compare XPath function. 

oXML.setProperty "SelectionLanguage", "XPath"
set node = oXML.selectSingleNode("Domains/DomainName[translate(.,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') =
'mydomain1.com']")
---------------------------------------------------------
So, going with the "translate" approach, all we had to do was add this
line:

     oXML.setProperty "SelectionLanguage", "XPath"

and then our translate worked fine.

Thanks for the input.

Hardy Merrill

Current Thread