Inserting XML into an HTML document
May 15, 2008 5:44 PM
Subscribe
I wish to insert a namespaced XML document into an (X)HTML web page. The "XML Data Island" trick is verboten. There appears to be two ways of accomplishing this. Both continue to elude me.
The first method is to use JS to fetch the XML document and then run a traversal on the document, re-creating its nodes as nodes appended to the insertion holder element. The second method is to use XSLT to not-transform it, but merely replicate it directly into the holder element.
The source XML document is Docbook with namespaces, so the TITLE element doesn't collide with XHTML's self-same element (otherwise I get a validation error). This XML will then be styled using CSS.
I've been exhaustively researching and toying with this for the past week. It seems to me to be a perfectly natural thing to want to do, yet for the life of me I have not found a pre-made solution.
I spent most of today working on the JS solution, and I think I've nearly grokked it, save a few stumbling details. But as I was driving home it struck me that (a) this is going to be unbearably slow for any large document; and (b) a simple not-really-transforming XSLT might do the trick.
Anyhoo, I'd like to hear some ideas for ways of solving all this. I'm a rank newbie at the whole JS/DOM thing, but familiar enough that I'm more or less successfully muddling through it through judicious use of the internets. Feel free to post code, etc; at this point any info I can get that'll help me struggle through this is welcome100.
posted by five fresh fish to technology (16 comments total)
1 user marked this as a favorite
posted by cschneid at 6:20 PM on May 15, 2008