Advantages of XML? Couple of questions...

TJN23

Golden Member
May 4, 2002
1,670
0
0
I'd just like some ideas....basically I've dealt with basic xml stuff:

-data binding
-parsing with javascript dom, java sax and dom,
-stylesheets,
-DTDs,
-XSLT

I have to write a paper stating how XML's advantages could be used to improve an existing website. This website is a college's foreign language computer center's main page (has faculty pages, student tools, etc)

it's currently coded using html, asp, and some javascript...

any ideas?? many thanks in advance...

Tim

p.s. please move if this isn't in the right forum
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
XML is basically a standard way of transporting data. XML can allow you to easily modularize a website the same way you would modularize any GUI application (Model-View-Controller). A website's model could be its database, the view would be its HTML and the controller would be the mechanism for translating database data into HTML. XML can simplify this process.

Database --> ASP-based XML generator -> XSL -> HTML

You can write your XML generator generically enough so that if your data model changes, you only need to update your XSL documents. If you want to change the site's design, you only need to update your XSL documents.

You can also build an XML-based web service that drives the website. You can then use the webservice to hook into other non-web applications that might want to use the site's data.
 

TJN23

Golden Member
May 4, 2002
1,670
0
0
Originally posted by: MrChad


You can write your XML generator generically enough so that if your data model changes, you only need to update your XSL documents. If you want to change the site's design, you only need to update your XSL documents.

I don't understand what you mean by writing my XML generator. Isn't there a package out there for an ASP-based XML parser?

I thought you meant that if my data changes, I only need to update my XML documents whereas if I want my design to change I only need update my XSL documents


Also, would there be any language capabilities XML could offer? maybe such as displaying the site differently depending on which audience is viewing it (i.e. a spanish audience vs. an american audience)

thx,

Tim
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
I meant that you could use ASP to query the database and write an XML document for the query results. For instance, I could have an articles table:

SELECT Author, Title, Text
FROM ARTICLES
WHERE Article_ID = 1

And my ASP page could generate:

<QueryResult><Articles><Article ID="1"><Author>Bob</Author><Title>Title</Title><Text>Text</Text></Article></Articles></QueryResult>

This XML gets transformed and generates the appropriate HTML. There may be some pre-existing ADO-to-XML components out there, but I don't use ASP much, so I don't know.

As for language capabilities, XML is just a way to transfer data. It won't have built-in translation capabilities, if that's what you mean. You could segment your data into different languages (on the database end), but I'm not sure how XML specifically could help you.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: MrChad
I meant that you could use ASP to query the database and write an XML document for the query results. For instance, I could have an articles table:

SELECT Author, Title, Text
FROM ARTICLES
WHERE Article_ID = 1

And my ASP page could generate:

<QueryResult><Articles><Article ID="1"><Author>Bob</Author><Title>Title</Title><Text>Text</Text></Article></Articles></QueryResult>

This XML gets transformed and generates the appropriate HTML. There may be some pre-existing ADO-to-XML components out there, but I don't use ASP much, so I don't know.

As for language capabilities, XML is just a way to transfer data. It won't have built-in translation capabilities, if that's what you mean. You could segment your data into different languages (on the database end), but I'm not sure how XML specifically could help you.

You could also use the native XML facilities of SQL Server, Oracle, etc., if that's what you're using. For example, in SQL Server 2k (and 7 w/ the XML toolkit--whatever it's called) you could do the following:

SELECT Author, Title, Text
FROM ARTICLES
WHERE Article_ID = 1
FOR XML AUTO, ELEMENTS

And get back the XML without having to manually generate it yourself. For those that do not have native XML facilities, you could use the Save method of the ADO Recordset with adPersistXML as the persistence type. You can even save the ADO Recordset to the Response stream directly. e.g.:

' get recordset
yourRecordset.Save Response, adPersistXML
' cleanup recordset

I used this method in one of my earlier architectures (circa '99 or so) that passed XML data between tiers as opposed to disconnected ADO Recordsets. I'm a firm believer that manually generating XML is a BAD thing indeed. I've seen people run into issues having to deal with all the entity references, etc., and it doesn't make for clean code.