Microsoft KB Archive/318890

From BetaArchive Wiki

Article ID: 318890

Article Last Modified on 10/16/2002



APPLIES TO

  • Microsoft XML Core Services 4.0
  • Microsoft XML Core Services 4.0 Service Pack 1



This article was previously published under Q318890

MORE INFORMATION

XSLT: Access Violation When Using Global Variables with Certain Patterns of Object Allocation and Deallocation in XSLT Stylesheet

When you call xmldoc.transformNode(xsldoc) with the following XSL stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                exclude-result-prefixes="msxsl" >

<xsl:variable name="rtf"><test/></xsl:variable>

<xsl:template match="/">
    <xsl:call-template name="call1"/>
    <xsl:call-template name="call1"/>
</xsl:template>

<xsl:template name="call1">
    <xsl:variable name="rtf2">
        <xsl:call-template name="call2" />
    </xsl:variable>
</xsl:template>

<xsl:template name="call2">
    <xsl:value-of select="msxsl:node-set($rtf)" />
</xsl:template>

</xsl:stylesheet>

                

you may receive the following access violation error message:

The instruction at "0x788b36df" referenced memory at "0xadadadad". The memory could not be "read".

back to the top

XSLT: Access Violation When Using a Global Variable that Converts a Forward XSLT Variable into a Node-Set

When you save the following XSL stylesheet as C:\Test2.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    exclude-result-prefixes="msxsl">

    <xsl:variable name="ns" select="msxsl:node-set($var1)"/>

    <xsl:variable name="var1">
        <test/>
    </xsl:variable>

    <xsl:template match="/">
        <xsl:variable name="ns" select="$ns"/>
    </xsl:template>

</xsl:stylesheet>

                

and you then call xmldoc.transformNode(xsldoc), you may receive the following access violation error message:

The instruction at "0x788cdcca" referenced memory at "0x00000004". The memory could not be "read".

back to the top

XSLT: Access Violation When a Node-Set with 0 or 1 Nodes Is Passed to a Stylesheet and Bound to a Global Variable

When you pass a node-set that contains zero nodes or one node, and you then bind the node-set to a global variable, you receive the following access violation error message:

The instruction at "0x788cdcca" referenced memory at "0x00000004". The memory could not be "read".

Steps to Reproduce the Behavior

  1. Create a new Microsoft Visual Basic 6.0 Standard EXE project, and then set a project reference to MSXML, v4.0.
  2. Save the following XSL stylesheet as C:\Test3.xsl:

    <?xml version='1.0' ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:param name="nodeVar"/>
    
        <xsl:template match="/">
            <xsl:apply-templates select="$nodeVar"/>
        </xsl:template>
    
        <!-- object element -->
        <xsl:template match="object">
            <test/>
        </xsl:template>
    
    
    </xsl:stylesheet>
    
                        
  3. Add a Button control to the form. Double-click the Button control, and then paste the following code in Command1_Click():

    Private Sub Command1_Click()
    Dim xmldoc As New MSXML2.DOMDocument40
    xmldoc.async = False
    xmldoc.loadXML "<test><object/></test>"
    
    Dim xsldoc  As New MSXML2.FreeThreadedDOMDocument40
    xsldoc.async = False
    xsldoc.Load "C:\test3.xsl"
    
    Dim xslTemplate As New MSXML2.XSLTemplate40
    Set xslTemplate.stylesheet = xsldoc
    Dim xslproc As MSXML2.IXSLProcessor
    Set xslproc = xslTemplate.createProcessor
    
    xslproc.input = xmldoc
    Dim nodelist As MSXML2.IXMLDOMNodeList
    Set nodelist = xmldoc.selectNodes("test/object")
    MsgBox nodelist.length
    xslproc.addParameter "nodeVar", nodelist
    xslproc.Transform
    
    MsgBox xslproc.output
    End Sub
                        
  4. Compile and run the project.

back to the top

XSLT: Context Is Lost When Multiple Documents Are Loaded by Using the Document() Function

When you use the XSLT Document function to load multiple documents, context information may be lost.

Steps to Reproduce the Behavior

  1. Create a new Visual Basic 6.0 Standard EXE project, and then set a project reference to MSXML, v4.0.
  2. Save the following XSL stylesheet as C:\Test4.xsl:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:variable name="configuration" select="document('xsltcfg.xml')"/>
    
    <xsl:template match="/">
         <xsl:apply-templates select="document('testcat.xml')/test" />
    </xsl:template>
    
    <xsl:template match="test">
    
            <xsl:variable name="category" select="@category"/>
    
        <xsl:for-each select="$configuration">
            category : <xsl:value-of select="$category"/>
            id($category) : <xsl:value-of select="id($category)"/>
            name(id($category)) : <xsl:value-of select="name(id($category))"/>
        </xsl:for-each>
    
    </xsl:template>
    
    </xsl:stylesheet>
    
                        
  3. Paste the following XML in C:\Test4.xml:

    <submissions configuration-href="xsltcfg.xml" discretionary-href="xsltdisc.xml">
      <submission href="testcat.xml" submitter="test" date="2001-07-19"/>
    </submissions>
                        
  4. Save the following XML as C:\Testcat.xml:

    <test id="first-test" category="XSLT-Result-Tree" />
                        
  5. Save the following XML as C:\Xsltcfg.xml:

    <categories>
        <category id="XSLT-Template">matching, call named, priority</category>
        <category id="XSLT-Result-Tree">creation of nodes in result</category>
    </categories>
                        
  6. Add a Button control to the form. Double-click the Button control, and then paste the following code in Command1_Click():

    Private Sub Command1_Click()
    Dim xmldoc As New MSXML2.DOMDocument40
    xmldoc.async = False
    xmldoc.Load "C:\test4.xml"
    
    Dim xsldoc  As New MSXML2.DOMDocument40
    xsldoc.async = False
    xsldoc.Load "C:\test4.xsl"
    
    MsgBox xmldoc.transformNode(xsldoc)
    End Sub
                        
  7. Compile and run the project. You receive the following output in a message box:

    category : XSLT-Result-Tree
    id($category) :
    name(id($category)) :


    You expect to see the following output:

    category : XSLT-Result-Tree
    id($category) : creation of nodes in result
    name(id($category)) : category


back to the top

XSLT: Incorrect Transformation When You Execute the document() Function Twice

If you perform two transformations on an XSLT stylesheet that contains the document() function, and you reset the stylesheet property on the IXSLTemplate objects with the same stylesheet before you perform the second transformation, the transformation result may be incorrect. When the MSXML parser executes the document() function, the parser loads the stylesheet based on its Uniform Resource Identifier (URI), then adds the URI of the stylesheet to an internal hash table (that is, the document URI hash table). However, this entry is only added to the hash table when the table is created the first time. When you reset IXSLProcessor for a new transformation, all entries in the document URI table are cleared. When you execute the document() function again, no URI entry exists for the stylesheet, which results in the incorrect transformation.

The following xsl:template calls document(), which loads the XSLT stylesheet:

<xsl:template match="object" mode="addFieldDefinitions">
  <xsl:copy-of select="document('')/*/qc:fielddefinitions/object[@name=current()/@name]" /> 
</xsl:template>
                

back to the top

DOM: Access Violation When Passing Null Node-Set to IXSLProcessor::addParameter with selectNodes Method

If selectNodes("test/test1") returns a null node-set, and you then run the following code

    Dim xOutput As MSXML2.FreeThreadedDOMDocument40
    Dim xInput As MSXML2.FreeThreadedDOMDocument40
    
    Set xInput = New MSXML2.FreeThreadedDOMDocument40
    xInput.async = False
    xInput.Load App.Path & "\input.xml"
    Set xOutput = New MSXML2.FreeThreadedDOMDocument40
    xOutput.async = False
    With xTemplate.createProcessor
        .input = xInput
        .output = xOutput
        .addParameter "tablespace", "bob"
        
        On Error GoTo errorHandler
        
        .addParameter "userLocations", xInput.selectNodes("test/test1")
        
        .Transform
    End With
    Text1.Text = xOutput.xml
    
                

you may receive the following access violation error message at the addParameter call:

The instruction at "0x788cdcca" referenced memory at "0x00000004". The memory could not be "read".

back to the top

DOM: Run-Time Error with transformNode() Method When xsl:apply-templates Is Used to Assign a Value to an xsl:variable Element

When you use the following code in an XSLT stylesheet

<xsl:variable name="TopSeller"><xsl:apply-templates select="//BookStore[@TopSeller='yes']" /></xsl:variable>
                

you may receive the following run-time error message with the transformNode method:

ERROR : Run-time error '-1073741795(c000001d)'

back to the top

XPath: Incorrect Results When Executing XPath Queries with position() Function Placed to Right of Certain Operators

When you parse the following XML data

<?xml version="1.0"?>
<ROOT>
  <M N="a"/>
  <M N="b"/>
  <M N="c"/>
  <M N="d"/>
  <M N="e"/>
</ROOT>
                

and you place the position() function on the right side of the < ,<= , >, or >= operators, as follows

xmldoc.setProperty "SelectionLanguage", "XPath"

'The following XPath query displays 2 as the output (this is the correct behavior).
MsgBox xmldoc.selectNodes("//M[position() > 3]").length

'The following XPath query displays 3 as the output (this is the correct behavior).
MsgBox xmldoc.selectNodes("//M[3 < position()]").length
End Sub
                

the length of the node list that the second selectNodes returns is 3, which is not correct:

mldoc.selectNodes("//M[3 < position()]").length
                

back to the top

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

318886 INFO: List of Issues Fixed in Microsoft XML 4.0 Service Pack 1 (Part 1 of 4)


318887 INFO: List of Issues Fixed in Microsoft XML 4.0 Service Pack 1 (Part 2 of 4)


318889 INFO: List of Issues Fixed in Microsoft XML 4.0 Service Pack 1 (Part 3 of 4)


Keywords: kbinfo kbbug KB318890