Solved

MSXML2 appendChild method fails in debugger only

Posted on 2002-05-28
8
535 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
Industry Leaders: 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

717 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