Solved

MSXML2 appendChild method fails in debugger only

Posted on 2002-05-28
8
522 Views
Last Modified: 2008-02-26
I have a method that will dynamically build an XML schema based on schema fragments provided by upstream clients.  The mergeSchema method takes the various fragments each time this method is called and merges them into the fullSchema .  At this point, the method is not eliminating duplicates, (that's what I'm trying to code)

On the line marked by '*****, I'm getting an error message when I work in the VB debugger, namely "The parameter is invalid".  But when I compile it and run, the same line does its work and executes.  Is there a way to work around this and still get the same behavior?


Private Sub IToldSchemaMerger_mergeSchema(schemaChanges As MSXML2.IXMLDOMNode, fullSchema As MSXML2.IXMLDOMNode, ByVal schemaID As Long)
    Dim currentItem As MSXML2.IXMLDOMElement
    Dim dupe As MSXML2.IXMLDOMNode
    Dim fullyMatchingNode As MSXML2.IXMLDOMNode
    Dim l_schemaBase As MSXML2.IXMLDOMNode
    Dim l_fullSchema As MSXML2.IXMLDOMElement
    Dim l_throwAwayElements As MSXML2.IXMLDOMNode
   
    Set dom = CreateObject("MSXML2.DOMDocument")
    m_schemaID = schemaID
    dom.loadXML (fullSchema.xml)

    Set l_throwAwayElements = dom.createNode(NODE_ELEMENT, "THROW_AWAY", vbNullString)
    Set l_schemaBase = schemaChanges.selectSingleNode("/SCHEMA_CHANGES")
    removeNSAttribute l_schemaBase
    Set l_fullSchema = dom.selectSingleNode("/schema")

    'for each complexType in schemaChanges,
    With l_schemaBase.childNodes
        While .length > 0
            Set dupe = duplicateEntry(l_fullSchema, .item(0))

'            if the complexType already exists
             If dupe Is Nothing Then
                'add the complexType to the schema
                l_fullSchema.appendChild .item(0)   '*****
             Else
                'compare more closely and either drop it or alter the complexType name
               Set fullyMatchingNode = identicalNodes(dupe, .item(0))
               If fullyMatchingNode Is Nothing Then
                    'remove the item from the schema additions
                    l_throwAwayElements.appendChild .item(0)
               Else
                    Set currentItem = .item(0)
                    mergeSimilarComplexTypes l_schemaBase, currentItem
                    'Set currentItem = Nothing

               End If
             End If
        Wend
    End With

    removeNSAttribute l_fullSchema

    Set fullSchema = l_fullSchema
End Sub
0
Comment
Question by:tom_uf87
8 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 7039483
What if you declare I_fullschema of type IXMLDOMNode instead of IXMLDOMElement?

Have you downloaded the latest service packs for the XML3.0 parser?
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7039722
You should change the progid to MSXML2.DOMDocument30 or MSXML2.DOMDocument40 and see if that makes a difference.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7039736
also, there is something interesting happening here:

If dupe Is Nothing Then
'add the complexType to the schema
l_fullSchema.appendChild .item(0)   '*****
Else

End If

You are using the While .length > 0
and then stripping one child from one DOM to another.

The debugger may be caching the length of the childNodes. The question here is at which point of the loop do you get the error message.
0
 

Author Comment

by:tom_uf87
ID: 7040095
Thanks for the ideas folks.

I tried IXMLDOMNode instead of IXMLDOMElement -- no difference


I'm using the MSXML4 parser, and got the latest service pack.


The interesting part,

l_fullSchema.appendChild .item(0)   '*****

is the essence of the method.  It is examining XML from l_schemaBase.childNodes, and throwing away exact duplicates or moving the unique items into the fullSchema.  One thing I tried was to put .item(0) in either an XMLDOMNode or XMLDOMElement.  It still fails on the appendChild step.  Again, this is only in the debugger.  Compiled it works as desired.  

Another thing I tried was to replace the above line with the following two lines:

Set nonMatchingNode = .item(0)
l_fullSchema.appendChild nonMatchingNode

I also tried DOMDOcument30 and 40, to no effect.

While it is nice that the compiled code works as desired, I'd like to have this working in the debugger so I can add functionality to the method.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 23

Expert Comment

by:b1xml2
ID: 7040585
One thing I noticed about the debugger is that in some circumstances, late-binding causes a problem. Why not use early-binding? It might solve the "bug".

Dim dom AS Msxml2.DOMDocument40
Set dom = New Msxml2.DOMDocument40
0
 

Author Comment

by:tom_uf87
ID: 7041642
Another good idea, but, alas, it made no difference.  I also re-read previous questions and realized I didn't answer the one about where in the looping process it fails.  The failure is the first time the appendChild is encountered.


This question could be phrased another way:
If I can't use this approach to appendChildren from another bit of XML to my main XML, what should I be doing?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7851199
Hi tom_uf87,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

tom_uf87, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7912828
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now