delphi - MSXML - Namespaces info not persisting -
i using msxml 6.0 perform transform of own xml xml format. not sure if maybe don't understand how msxml works, believe have noticed strange behaviour it....
i adding in namespaces xml doc using setproperty method e.g.
xmldocument.setproperty('selectionnamespaces', ' xmlns:ms=''http://mydomain.com/2010/myschema''');
then building xml using own custom serializer in memory (not saving disk). once serialized load in xslt file , perform transformation using transformnodetoobject e.g.
appxmldoc.transformnodetoobject(xslxmldoc, astreamfortransformedxml);
the problem transform working none of specific template matching xpath have in is. eliminated problems xslt file running test data through visual studio , worked expected. assumed must have been encoding issue made sure documents involved being read/written out utf-8....still no luck.
here example of transform looks like:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:ms="http://mydomain.com/2010/myschema" exclude-result-prefixes="ms"> <xsl:template match="/"> <aroot> <head> <xsl:apply-templates select="ms:element/ms:subelement" /> </head> <body> <xsl:apply-templates select="ms:element/ms:differentsubelement" /> </body> </aroot>
so result of transform when run through msxml brings on basic structure not include of template data. after testing discovered way work in following steps:
- create new xml doc
- set namespace info using
setproperty
- serialize xml , save disk.
- close document - extra step
- create new xml doc - extra step
- reload document - extra step
- re-set namespace info - extra step
- perform transform.
so appears msxml loses track of namespace information @ somepoint. makes more weird if reset namespace info (after serializing) , try transform still doesn't work! seem work if save document, close , recreate new xml document , load in (which consequence need reset namespaces).
anyone have thoughts/ideas on this?
the selectionnamespace property used xpath selectnodes , selectsinglenode methods, not xslt or other purposes. not sure why set , expect not seem use selectnodes or selectsinglenode. want achieve msxml 6? if want create msxml dom documents elements and/or attributes in namespaces make sure use createnode namespace aware method in msxml's api.
Comments
Post a Comment