Click to See Complete Forum and Search --> : Help with XSL transform XML to specific HTML
dlink
05-12-2009, 10:57 PM
I got the task:
If you open XML in browser it shows with "+" and "-" signs so you may
collapse or expand XML nodes.
How I can made XSL which will transform XML into HTML.
And this HTML will show the XML and got ability to collapse or expand XML nodes.
Any suggestions.
themarty
05-13-2009, 04:38 AM
You can not transform it into HTML, only into XHTML.
But what is really your problem? If it's the XSLT part, reading this should give you an idea how to start:
http://www.w3schools.com/xsl/
Most modern browsers already do what you want to accomplish though. Just open any xml file in Firefox or IE and they will display it exactly like you want to.
dmboyd
05-13-2009, 08:35 AM
Most modern browsers already do what you want to accomplish though. Just open any xml file in Firefox or IE and they will display it exactly like you want to.
With the exception of Firefox 3.x apparently... The same-origin policy that applies to JavaScript is applied to local files as well now. To allow local files to be used as mentioned, you need to go into about:config and set "security.fileuri.strict_origin_policy" to false. Of course, NoScript users would also need to allow "file:" URIs. :p
See the changes to the same-origin policy (https://developer.mozilla.org/En/Same-origin_policy_for_file%3a_URIs). Note that this also affects framesets, according to that document.
dlink
05-13-2009, 12:02 PM
This is the test task =)
I want to find good examples of same XSL
(or/and ready JS)
Charles
05-13-2009, 12:26 PM
You can not transform it into HTML, only into XHTML.That's a lie and anybody who says differently is itching for a fight. You can transform XML into pretty much anything with XSL.
dmboyd
05-13-2009, 02:12 PM
That's a lie and anybody who says differently is itching for a fight. You can transform XML into pretty much anything with XSL.
That's true... If your HTML isn't also well-formed XML (e.g. you include <img> or <link> or <br> or leave off the end tag for <p>), that's not a problem. After all, you can always output as text if the XSLT processor doesn't like what you write. ^_^