troubleshooting Question

Cannot Create MSXML 4 dom with XSL

Avatar of NikWhitfield
NikWhitfield asked on
XML
3 Comments1 Solution584 ViewsLast Modified:
Hi,

   I want to create a DOMDocument40 which is in fact an XSL template. The root is obviously <xsl:template> which contains namespace attributes. I use the following code in VB:

Dim objDOMDoc As DOMDocument40
Dim objProcInstruction As IXMLDOMProcessingInstruction
Dim objRootElement As IXMLDOMElement
Dim objNode As IXMLDOMElement
Dim objXSL As IXSLProcessor

    '**********************************************************************
    'Initialise the output DOM Document
    '**********************************************************************
    Set objDOMDoc = New DOMDocument40
    objDOMDoc.validateOnParse = False
    objDOMDoc.setProperty "SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:fo='http://www.w3.org/1999/XSL/Format'"
   
    'Create Processing Instruction
    Set objProcInstruction = objDOMDoc.createProcessingInstruction(mcXML, mcXML_VERSION_TAG)
    Set objProcInstruction = objDOMDoc.appendChild(objProcInstruction)
    'Create Root Node
    Set objRootElement = objDOMDoc.createNode(NODE_ELEMENT, "xsl:stylesheet", "")
    'Add XSL namespaces
    objRootElement.setAttribute "version", "1.0"
    objRootElement.setAttribute "xmlns:xsl", "http://www.w3.org/1999/XSL/Transform"
    objRootElement.setAttribute "xmlns:fo", "http://www.w3.org/1999/XSL/Format"


The problem is on the CreateNode line, it moans about the fact that 'xsl' is an undeclared namespace prefix, even though I've used setProperty to inform it of them. If it's relying on an attribute declaration, this can't happen until the node's been created! So, anyone know how to get around this dilemma and create the XSL?

Cheers,

   Nik
ASKER CERTIFIED SOLUTION
BigRat

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros