Solved

MSXML2 appendChild method fails in debugger only

Posted on 2002-05-28
8
529 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

749 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