Forum Moderators: open

Message Too Old, No Replies

XSLT Only Works One Way?

Converting XML into XHTML

         

ahamilton9

4:23 am on Jun 22, 2006 (gmt 0)

10+ Year Member



I just finished reading an article and studying examples of how to use XSLT to transform an XML document into a readable XHTML document. Problem is, I have an XML document I want to extract one little bit of, change it from a number to an understandable statement (from 1/0 to on/off, etc...) and place the info INTO an XHTML document. I have no access to the page because it is automatically output by my server software and if I were to append the required link to it, it would be over written. Is there a way I could attach an XML doc to an XSL doc instead of the other way around (which I'm guessing is a no) or is there another work around? I only need on bit of info out of the document but I cant seem to display it on my webpage. Thanks in advance.

Iguana

9:25 am on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Should I answer this thread or the other one on the same subject? I think you need to slow down a bit.

XML has the data. XSLT can tranform that data into a Markup Language (HTML or XHTML). You will need to run XSLT on a Server (most Linux and MS servers can run XSLT). Or you could even use ASP or PHP to grab the XML and display it how you want to without bothering with XSLT since the changes you want to make are pretty small.

So, do you have access to these facilities on your server?

If not, then you can achieve a similar result on the client using either Flash or AJAX. Which you choose depends on your current skills and experience and what you want to do with it.

Assuming little experience with these technolgies, then Server Side ASP or PHP is the easiest route.

choster

2:28 pm on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, taking it step by step:

  • You have an XML source that you will transform with XSLT to output an HTML or XHTML snippet
  • You want this snippet inserted into another HTML or XHTML document
  • You can change the content of this second HTML/XHTML, but have no control over the server-side coding which generates it

Fundamentally, then, this is not an XML question, it's a question about how to include external content in a web page. In that case, here are some options for you:

  1. deliver the content in an <iframe>
  2. instead of HTML/XHTML, massage your XSLT so it outputs Javascript, which you can then import using a <script type="text/javascript" src="mydata.js"></script>. For users without Javascript or where it is disabled this is a bad option, but it will get the job done, after a lot of createElements.
  3. use Javascript (e.g. document.implementation.createDocument or Microsoft.XMLDOM) to import the XML (source or output) directly.

ahamilton9

3:14 pm on Jun 22, 2006 (gmt 0)

10+ Year Member



Sorry for the multiple post... I thought once I knew of XSLT I could explain this better here. I guess I'm just going to brush up on my Flash and see if I can write something to display it. Thanks.