Developer forum

Forum » Development » Adding xml data to Rendering.Template

Adding xml data to Rendering.Template

Steen Nørgaard Perdersen
Reply

I have a question/request.

 

Problem:

1. I have XmlDocument/XmlNode from other source/code/webservice/whatever

2. I want the contents to be available to processing in an xslt template.

 

It seems stupid to iterate an xml document, creating loops, setting tags to provide the data as xml for the xslt-template. Adding xml with setTag escapes the contents.

 

Any available methods to add the xml to the internal property XmlDocument? If not, I have these suggestions:

 

var doc = new XmlDocument();

doc.Load(HttpContext.Current.Server.MapPath("/Files/XML1.xml"));

var template = new Dynamicweb.Rendering.Template("/Module/test.xslt");

//Suggestion 1: Node is added to the internal property XmlDocument

template.SetTag("test", doc.DocumentElement);

 

//Suggestion 2: Internal property XmlDocument is made public.

XmlNode importnode = template.XmlDocument.ImportNode(doc.DocumentElement, true);

template.XmlDocument.DocumentElement.AppendChild(importnode);

 

 

 

Tn TemplateV2.Template the XmlDocument was accessible...

 

regards,

 

Steen

 

 

 

 

 

 

 

 

 


Replies

 
Vladimir
Reply

Hello Steen,

The post more suitable for feature requests section 

But the issue interesting, thank you! I will discuss it with the developers, will keep you up to date!

 

Kind regards,

Vlaimir

 
Steen Nørgaard Perdersen
Reply

Hi Vladimir,

thanks for the response. I will gladly repost in feature request section as the issue for us is still very present. Furthermore we are at present developing a new version of the module in question, so any chance of implementation with in a foreseeable future would be great.

Just for fun/info I can tell how we went around the limitations using current Rendering.Template:

1. create new Rendering.Template object using xslt with no output (emply)
2. set whatever tags/loop that can be set with out lots of data
3. make separate xmldoc with raw xmldata from external-sources
4. calling Output() just to trigger generation of globals + added tags
5. Reflection to get the xml document
6. Merging with the separate xml document
7. Re processing using the actual xslt to get final output.

What can I say.... doable but troublesome. Still much much faster that implementing getLoop/setTag for each and every object in the external source xml.

 

Best regards,
Steen/Bleau

 

 

 

 

 
Vladimir
Reply

It is clever workaround :)) However I hope we can avoid that voodoo magic in a future :)

 
Vladimir
Reply

Hi Steen,

uh ... my enthusiasm by your proposal was not supported by other... 
I was offered another option instead, make:

    settag("data", base.xmlxsltparse(xmlData, xsltTemplate))

Is it will work for you?

And next week will a big meeting. The templates will also be discussed, so I think it will be some interesting news.

 

Best regards,

Vladimir

 

 
Steen Nørgaard Perdersen
Reply

Thaks for caring!

 

Unfortuneatly everything i throw in a SetTag gets encoded, so theres so selecting values with xpaths/looping.... i could script this to a node... buts even more troublesome.

 

 

 

 

You must be logged in to post in the forum