homepage Welcome to WebmasterWorld Guest from 50.17.176.149
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
using xml to hold pages html
dynamic html from CMS being dumped into XML/XSLT files.
AWSwS




msg:3897740
 1:31 pm on Apr 22, 2009 (gmt 0)

Hi All,

I've recently started a new project in ASP.Net, I've come across a little hurdle that I'm currently unsure of how to do.

I'm trying to keep this new CMS development away from databases as much as possible, although it will use a database for specific items.

I am wondering if the following is possible:

user logs into the site, decides to create a new 'page' via the cms's page bolt-on, the user enters the title, meta tags, description, then finally a chunk of html/content to design the page.

this information i wish to store in XML/XSLT file. obviously i don't know how much information will be placed into this CMS bolt on. it could be a simple

<h2>bla bla bla </h2>
<p>blah blah blah moo baa woof</p>

or a full range of <div>'s and <table>'s etc

is there a way for me to dump the content into a xml file and the relevant html into an XSLT dynamically?

I've searched google with no results that have helped, although a few other questions were answered, so some benefits.

Thanks for any responses.

Regards

awsws

 

httpwebwitch




msg:3899650
 2:33 pm on Apr 24, 2009 (gmt 0)

Hi AWSwS,

I'm trying to keep this new CMS development away from databases as much as possible

I'm wondering why you would want to do that? Is it a technical requirement? Databases are fun. And they do a wonderful job of storing and retrieving blocks of HTML content.

is there a way for me to dump the content into a xml file and the relevant html into an XSLT dynamically

yes, using ASP.NET you can open a file, write to it, then save it.

I've searched google with no results that have helped

MSDN is overflowing with great tutorials to help you.
here's one:
[msdn.microsoft.com...]

AWSwS




msg:3899664
 2:44 pm on Apr 24, 2009 (gmt 0)

Theres no technical requirement, i've done CMS's using databases to store the page content, but this is abit of a fun challenge.

as for the dumping of html into xml, i know i can write to files etc, i was looking more of how i would go about the whole html into xml part.

the issue i had was basically i can't just dump user generated html into the xml file like i can a database, i need to (or so i believe) identify the html tags, build the xml file based on the textual content and then link each html tag into the xslt file. i believe i'm not explaining myself very well, i will take a good stab at it on the weekend.

Thank you for the msdn link, i can save text to xml files no issue, as i use xml files for configuration purposes within this cms site.

i may bite the bullet in the end and just build the content part of the cms using a database table. but its a fun challenge to find out if i can do it in xml.

Once again thank you for the response.

httpwebwitch




msg:3899800
 4:39 pm on Apr 24, 2009 (gmt 0)

i can't just dump user generated html into the xml file like i can a database

Actually, you could.
Wrap the HTML in a CDATA node, to indicate that the value of the node is character data content. Then the wacky HTML entered by your users won't interfere with parsing the XML.

for example:

<page>
<author>Joe Blow</author>
<title>my first web page</title>
<lastmodified>2009-04-22 12:02:45</lastmodified>
<content>
<![CDATA[
<p>This is my first web page</p><font size="100">WOOT!</font><blockquote>I am so cool it hurts</blockquote>
]]></content>
</page>

I agree it would be quite a challenge to parse the HTML, put text nodes into XML and generate an XSLT to put it back together again. The advantage would be to allow people to enter a block of HTML, then use that page to generate similar pages with the same layout (a template, if you will).

But alas, the disadvantages... There are so many complications when parsing HTML. For instance, how would you handle an <img> node, or an <iframe> where the important content is an attribute, not a child node? And how would you handle badly-formed HTML, misnested tags, <script> tags, etc? Will you support SVG or <canvas>? Will you treat <style> as content data in the XML, or layout in the XSLT? And what about embedded Flash? and so on...

And then there's this gem:

<p>I am feeling <b>good</b> today.</p>

The "p" node has 3 children: a text node, followed by a "b" node with a text child, then another text node. Piecing that together into an XSLT layout would be a nightmare. You'd end up with 3 tiny chunks of content in your XML, and an XSLT that expects three bits of text to inject into it. A situation which doesn't do the document justice.

Sounds like an interesting project. Be careful not to get sidelined by inventing challenges where simpler solutions exist. That's my $0.02 :)

AWSwS




msg:3900222
 7:21 am on Apr 25, 2009 (gmt 0)

How could i have overlooked cdata, your right inventing challenges for ones self is not a wise idea.

Thank you.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved