-1

How to XSLT-transform in-memory xml DOM tree? For example I create(with DOM) in memory XML tree and want to XSLT-transform it. I want to omit phase of serializing created DOM tree in XML and then send xml serialized document to XSLT processor(that will waist time to deserialize it again). Just directly send DOM tree as input to XSLT processor. Implementation in MSXML is preferable.

Vlad
  • 1,977
  • 19
  • 44
  • There is a `transformNodeToObject` method you can use in the MSXML API to transform a DOM node to another DOM node (for instance an empty DOM document node created by (example in JScript) `new ActiveXObject('Msxml2.DOMDocument.3.0')` for instance. Consider to show your existing code, then we can better understand what you are trying to do and how to change your code. – Martin Honnen Apr 27 '15 at 10:42
  • I'm only investigating the possibility to use XSLT to my task so unfortunately there is no code yet. – Vlad Apr 27 '15 at 10:44
  • I need this sequence: in-memory C++ object -> create DOM tree -> XSLT transform -> serialize to XML. And NOT this: in-memory C++ object -> create DOM tree -> serialize to XML 1-> XSLT transform -> obtain XML 2. – Vlad Apr 27 '15 at 10:48

1 Answers1

1

With MSXML a DOM node exposes methods transformNode (taking a DOM node with the stylesheet code as its argument and creating a string with the transformation result, see https://msdn.microsoft.com/en-us/library/ms761399%28v=vs.85%29.aspx) and transformNodeToObject (taking a DOM node with the stylesheet code as its first argument and a result object like a stream or another DOM node as the second argument, see https://msdn.microsoft.com/en-us/library/ms766561%28v=vs.85%29.aspx) so it is easy to apply XSLT to a DOM node created in memory.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • Thank you, So, is it correct that it's possible to create chain of **in-memory** transformations: (DOM object 1, stylesheet1) -> XSLT processor ->DOM object 2; (DOM object 2, stylesheet2) -> XSLT processor ->DOM object 3; And only in the end serialize result to XML? – Vlad Apr 27 '15 at 10:59
  • Yes, using `transformNodeToObject` it is possible to populate an empty DOM document node with the result of a transformation and of course then you can call `transformNode` or `transformNodeToObject` again to further process the first result. – Martin Honnen Apr 27 '15 at 11:02