Dynamicweb’s XML for ParagraphSetup and how I would change it
I was playing a bit with XSLT templates in Dynamicweb and found some things in the XML dump, that I would have made in another way, and maybe even a more dynamic way if you ask me. So I thought to my self, that I won’t just sit and bitch to my self about it. I would like to hear other peoples opinion on this and who knows, if I’m right on this one, then Dynamicweb might make the change, if I’m wrong about it, well then I will probably learn something new with in this post.
XML
Lets have a look at the XML dump, that Dynamicweb provides us for developing XSLT snippets.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <Template> <ParagraphHeader></ParagraphHeader> <ParagraphText></ParagraphText> <TemplateMedia1></TemplateMedia1> <TemplateMedia1Clean></TemplateMedia1Clean> <TemplateLink1></TemplateLink1> <TemplateMedia2></TemplateMedia2> <TemplateMedia2Clean></TemplateMedia2Clean> <TemplateLink2></TemplateLink2> <TemplateMedia3></TemplateMedia3> <TemplateMedia3Clean></TemplateMedia3Clean> <TemplateLink3></TemplateLink3> <TemplateMedia4></TemplateMedia4> <TemplateMedia4Clean></TemplateMedia4Clean> <TemplateLink4></TemplateLink4> <TemplateMedia5></TemplateMedia5> <TemplateMedia5Clean></TemplateMedia5Clean> <TemplateLink5></TemplateLink5> <TemplateParagraphHeader1></TemplateParagraphHeader1> <TemplateParagraph1></TemplateParagraph1> <TemplateParagraphColumn1></TemplateParagraphColumn1> <TemplateParagraphHeader2></TemplateParagraphHeader2> <TemplateParagraph2></TemplateParagraph2> <TemplateParagraphHeader3></TemplateParagraphHeader3> <TemplateParagraph3></TemplateParagraph3> <TemplateParagraphHeader4></TemplateParagraphHeader4> <TemplateParagraph4></TemplateParagraph4> <Server.Request.id>540</Server.Request.id> <Server.Request.purge>True</Server.Request.purge> <GlobalTags></GlobalTags> </Template> |
The part that I’m going to focus on is the way Dynamicweb is looping paragraphs that are part of ParagraphSetup. I find it inappropriate to loop nodes with same type of content and give them unique name. That makes it harder for developers to make XPath selection that loops same type of nodes. If you ask me how I’ll make this XML dump, my answer will be like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <Template> <ParagraphHeader></ParagraphHeader> <ParagraphText></ParagraphText> <TemplateMedia name=”TemplateMedia1”> <TemplateMediaHtml></TemplateMediaHtml> <TemplateMediaClean></TemplateMediaClean> <TemplateLink></TemplateLink> </TemplateMedia> <TemplateMedia name=”TemplateMedia2”> <TemplateMediaHtml></TemplateMediaHtml> <TemplateMediaClean></TemplateMediaClean> <TemplateLink></TemplateLink> </TemplateMedia> <TemplateParagraph name=”TemplateParagraph1”> <TemplateParagraphHeader></TemplateParagraphHeader> <TemplateParagraphContent></TemplateParagraphContent> </TemplateParagraph> <TemplateParagraph name=”TemplateParagraph2”> <TemplateParagraphHeader></TemplateParagraphHeader> <TemplateParagraphContent></TemplateParagraphContent> </TemplateParagraph> </Template> |
As you can see all I did was just to groupe my nodes and gave them names by attribute. This way we can easy make a XPath selections that loops all Paragraphs by simply making a template match=”TemplateParagraph” and then output our templates without the need to know how many we have or what number they are. And if we want to only select a specific TemplateParagrah node, well then we can just call our match like this: match=”TemplateParagraph[@name='TemplateParagraph1']” . The same goes for the media nodes.
Conclusion
By making the XML output the way as I suggested, I believe that it will give us developers more dynamic and flexibility to our XSLT snippet, and our XSLT snippes would be easy to rewrite and use for other solutions aswell, since we won’t need to know, how many paragraphs user have posted to be able to name our nodes correct and get access to our content. I also believe that this is just one of many ways in how Dynamicweb could “optimize” there XML output, that will make Dynamicweb xslt snippets even more dynamic.
But all this will be a hard fix for Dynamicweb to make, since it will have major impact in all online Dynamicweb solutions that are using this XML output and XSLT snippets to create templates with. So if there should be another way in how to fix the current XML output then it might look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <Template> <ParagraphHeader></ParagraphHeader> <ParagraphText></ParagraphText> <TemplateMedia1 type=”MediaHtml”></TemplateMedia1> <TemplateMedia1Clean type=”MediaClean”></TemplateMedia1Clean> <TemplateLink1 type=”MediaLink”></TemplateLink1> <TemplateMedia2 type=”MediaHtml”></TemplateMedia2> <TemplateMedia2Clean type=”MediaClean”></TemplateMedia2Clean> <TemplateLink2 type=”MediaLink”></TemplateLink2> <TemplateParagraphHeader1 type=”TemplateParagraphHeader”></TemplateParagraphHeader1> <TemplateParagraph1 type=”TemplateParagraphContent”></TemplateParagraph1> <TemplateParagraphHeader2 type=”TemplateParagraphHeader”></TemplateParagraphHeader2> <TemplateParagraph2 type=”TemplateParagraphContent”></TemplateParagraph2> </Template> |
Again it will be best if he had some kind of clean loop option. This example might be a good solution for Dynamicweb since it won’t change the XML structure but just add attributes to it, meaning websites that are online/live won’t fail because of the change in XML output. And developers will be able to make easy and dynamic loops, simply by using the attribute name to groupe nodes.
What do you think about all this? Do you have a better way or is the current Dynamicweb XML output perfect?
Great post Srdjan – been having the same thoughts (well rants, really :-) when working with DW XSLT.
Your first example is the way to go, if you ask me… the XML output from Dynamicweb doesn’t look like it’s been “developed” but rather more like ‘Oh – click the “Output as XML” checkbox in some DataSet Exporter’.
I actually think they could change it by implementing namespaces or some kind of version attribute – our XSLT could use a processing-instruction to politely “ask” for the new format, so existing solutions wouldn’t have to be touched.
Yeah, calling the new XML through namespaces or attributes as you said, would be a smooth transformation from the old XML and the correct way to go.
Awesome that you share your thoughts on this one.
I totally agree that it’s definately not the perfect way they are doing it right now.
Your idea of nesting the related tags is great (why didn’t they do it in the first place?!?).
Let’s see if they agree on this one.
Kevin -> I ask my self the same question. We all know that Dynamicweb have some hardcore .NET developers. So it is kinda strange that nobody was asked if this was the right way to output a XML data.
A lot of improvements could (and should) be done to the XML output from Dynamicweb, and your first example is deffinetly a step in the right direction.
I hope they see this post, and do something about it :-)
Awesome ideas, great to see someone laying them out in the open.
IMO “Designs and Layouts” is the way to go, and i’d like to see Dynamicweb make that work with XML, and since it doesn’t support XML/XSLT yet, they can make it awesome to begin with :-)
Regards
Martin
@Martin -> Yup, they can make some nice things with that CMS if they only want to. I mean they bought Synkron Via, and if you ask me then I’ll say that Synkron Via have a great XML / XSLT workflow, so why not take a look at it and implement the same workflow into Dynamicweb.
Btw Martin, am I totaly wrong, if I say that you took HTX in Grindsted or something like that? I remember you face from somewhere and belive it was from Grindsted HTX.
I took HTX in Grindsted, but it’s been a while, and i don’t recall you by your name alone :-)
Where you HTX aswell?
@Martin Yeah I also went to HTX in Grindsted. I think I was on my first year while you ware on 2end or 3rd. We didn’t talk or anything. I just remember you visiting our class. Think you ware talking with “Mikkel Gejl Hansen” or was it “Morten Hyldgaard” 100% sure about it.But that was long time ago, anyways hehe
Thanks for “bitching” in public – If you did not speak up we would not be able to improve…
We’ve looked at your suggestions and have built something in Dynamicweb for paragraph setup templates that should meet your whishes.
Medias are now available in a loop as well in the existing way. So when using a xslt template a loop looking like this is available:
<![CDATA[]]>
Files/Billeder/AutumnLeavesSmall.jpg
Default.aspx?ID=126
Looping the paragraphs is not an option due to the existsing architecture, but tags have been extended to have a type attribute:
More on Dynamicweb 2
<![CDATA[Dynamicweb]]>
<![CDATA[Dynamicweb]]>
Let me hear your comments on this – it can be ready for 7.2 out soon.
Best regards, Nicolai @ Dynamicweb.
And a forum thread so you can actually read the xml:
http://engage.dynamicweb-cms.com/Forum-5.aspx?action=ShowThread&ThreadID=2237
This comment form is realy not happy for html inputs :(
@Nicolai -> I think that this kind of constructive feedback can give you more inputs and as I said I might be wrong on my XML examples. So I don’t know if it is “bitching” since I do like working with Dynamicweb CMS, and took my time to show my version of how things could be done.
But it is nice to see that you do pay attention and wanna make a change that will make life more smooth for fronend developers.
I’ll bee looking forward for Dynamicweb 7.2