Forum Moderators: open

Message Too Old, No Replies

Using XML/XSL for website

A few kinks in my plans...

         

Blue_Jeans

4:47 am on Apr 10, 2008 (gmt 0)

10+ Year Member



I am creating a new website and all of my cusomter's data so far has been really easy to do in xml... and I mean ALL of the data. My only concern is when the client needs something such as a hyperlink in their content, how am I to deal with it?

Basically, my site is set up like this:
A standard xml file with a server-side include to include a another xml file. The included xml file is a testimonials file, and it is only for convenience sake.
Each xml file links to a php page being served as xsl. It passes 1 thing, a name to identify which page was served to it. That page then includes some generic header and navigation xsl files, and then includes one xsl based on what content was sent. So far, everything has been working good.

The only concern I have is eventually the client will want a hyperlink embedded in the content... How am I to do this? I mean, if it just needs a link that kind of stands by itself, it isn't that hard to do. I'm already doing it. How would you make a link out of something inside of a bunch of text?

[edited by: jatar_k at 5:34 pm (utc) on April 10, 2008]
[edit reason] no urls thanks [/edit]

cmarshall

10:21 am on Apr 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Blue_Jeans, welcome to WebmasterWorld!

I'm not exactly sure what the issue is. It is very easy to make anchor elements (<a> elements) in XSLT.

By the way, we are not allowed to post links, so someone will probably remove the link to your site.

Blue_Jeans

8:39 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



I figured standard rules for forums applied... no links? wow... without the link it is impossible for you to understand what I meant..

Anyways, I think I figured out my problem. If not I'll post here again.

Blue_Jeans

9:16 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



Okay, question:

Let's say I have HTML tags inside of an XML tag. The XSL attribute disable-output-escaping="yes" fails in Mozilla browsers. So what are my options for displaying HTML tags in a browser?

cmarshall

9:50 pm on Apr 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use CDATA Sections [w3schools.com] (They let us post URIs to some well-known sites).

However, HTML is, for all intents and purposes, XML (if you use XHTML-compliant HTML, as I do). I don't see why it can't be a regular part of the XML.

Blue_Jeans

10:16 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



The intent was to enable a client to use any HTML element inside of a content tag in XML and it would "just work". Also, my CDATA sections display the < and > as that, meaning it is not interpreted as HTML.

My personal HTML is XHTML compliant, it is theirs I am worried about...

Will creating an xml template for every basic HTML tag and then applying the templates work? In my head it will, at least...

cmarshall

1:17 am on Apr 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Will creating an xml template for every basic HTML tag and then applying the templates work?

Yes. In fact, I recommend it. It will be better security, and you can restrict functionality (reduce the number and scope of attributes, etc.).

httpwebwitch

7:29 pm on Apr 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Blue_Jeans,
welcome to WebmasterWorld!

To clarify the "no links" policy, the intent is primarily to discourage people who post self-promotional links. Thus we encourage members to discuss topics using descriptions and short code samples, not with links to examples. Also, these links ("see my work in progress here") tend to disappear quickly or change, thus do not have lasting value to others who may find this thread in a search some year in the future.

However. Links to authority sources are almost always allowed (MSDN, Mozilla, PHP.net, W3C, places like that), as are links to quoted sources or specific "permalinked" content, like news stories or blogs. It's ultimately up to the discretion of the forum moderators, who (at worst) will remove the link and send you a friendly note explaining why.

Back on topic... I feel your concern. Give a client the ability to edit XML content, and it's just a matter of time before you get a panicky call asking why everything broke (like, they put in an unclosed "<BR>" tag). You do want them to be able to add a <table> or a <a> to their content, but you know that it's a double-edged sword. When you're merely rendering the content on page, they might bugger up the layout with an extra </div>, but when you're using XSLT they can fubar the entire site.

Other sites allowing user-generated content (UGC) often employ non-HTML markup, like BBcode or Wikistyle. There is a good reason for this. No one would have gone to the effort of creating alternative markup language if it wasn't tragically necessary.

Another approach is to pasteurize all the UGC with a function like htmlentities(), killing all HTML and turning it into "&lt;safe&gt;" markup. Then you can selectively find and replace "allowed" tags using regular expressions that turn "&lt;b&gt;this&lt;/b&gt;" back into "<b>this</b>".