473,811 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML, XSLT and modifying the DOM w/Javascript

Hi folks, I've got what I think is an interesting problem that I'm
having trouble finding a solution for. I have an XML document that I
render to the browser via an XSLT transformation to XHTML. I want the
output to include links to a JavaScript routine that I will write to
modify the original XML, but it seems that once the XML is rendered to
XHTML it is no longer in scope of the DOM; only the XHTML output is. IS
there any way to get DOM-level access to the original XML?

Thanks,

Shawn

Mar 10 '06 #1
4 1769

scoomey wrote:
I have an XML document that I
render to the browser via an XSLT transformation to XHTML. I want the
output to include links to a JavaScript routine that I will write to
modify the original XML, but it seems that once the XML is rendered to
XHTML it is no longer in scope of the DOM; only the XHTML output is. IS
there any way to get DOM-level access to the original XML?


Are you using client-side XSLT, that is you let the browser transform
the XML? In that case with IE 6 and MSXML 3 the original XML DOM
document is exposed as the property
document.XMLDoc ument
of the HTML DOM document.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 10 '06 #2
Bingo! Thanks Martin.That's exactly what I am doing. I'm going to gove
that a try. I wish there was a cross-browser way to get to the XML
tree, but if not I can live with IE6.

Mar 10 '06 #3
It worked perfectly. I was able to modify the underlying XML without a
problem... however, is there a way now to "re-apply" the XSL
transformation so that the view reflects the changes to the underlying
XML DOM?

thanks!

Mar 10 '06 #4


scoomey wrote:
I was able to modify the underlying XML without a
problem... however, is there a way now to "re-apply" the XSL
transformation so that the view reflects the changes to the underlying
XML DOM?


That is possible in theory as those are MSXML DOMDocument objects with
e.g. a transformNode method so you have
document.XMLDoc ument
and
document.XSLDoc ument
as well where then
document.XMLDoc ument.transform Node(document.X SLDocument)
would give you the string result of the new transformation. Thus if you
only want to do that once then
function showTransformat ion () {
var xmlDocument = document.XMLDoc ument;
var xslDocument = document.XSLDoc ument;
document.open() ;
document.write( xmlDocument.tra nsformNode(xslD ocument));
document.close( );
}
showTransformat ion()
should do.

But in general you probably don't want to run the complete
transformation and overwrite the complete document but rather you might
want to change some part of the XML and then update only part of the
HTML document. There is however no direct support for that, you will
somehow need to build your own update function and mechanism.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2714
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron extension responsible for the xslt functions. The problem i have is that the obtained transformation is not the waited one. I try to proccess the same XML file with XSL file with a program called XMLspy and i obtained the desire and waited...
7
4130
by: RC | last post by:
First, let me say I couldn't find a group discuss XML/XSLT. So I only choose the closest groups to post this message. Here is part of my *.xsl file <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:my-javascript-ext="my-ext1" extension-element-prefixes="my-javascript-ext"
6
4694
by: RC | last post by:
Hello World, I am try do call a JavaScript function from XSLT, but I got function not avaible error. See "????" below. Would someone out there tell me how? Thank Q! <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" /> <xsl:template match="/">
6
1520
by: Prashanth Ellina | last post by:
Hi, I am an XSLT newbie. I need to solve something which I will express in pseudo-code. function f1() { xmltree = <emptydom> addnamevaluepair(xmltree, "size","100") addnamevaluepair(xmltree, "color","blue")
0
2361
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag, such as a div with a runat=server. I can somewhat do this if I create a server control and include the control within the html div tag but this method (borrowed from ASP.NET Website Programming by Wrox press thanks guys) does not give me the full...
1
1640
by: John Moore | last post by:
I have a set of code that is called on every page load that loads an xslt file. The xslt file has an embedded <script> tag. Loading the page mutliple times causes aspnet_wp.exe to use all available memory and then reset. As this happens several times over the course of an 8 hour stress run, I'm looking for a solution. The xslt file has the following: <xsl:if test="$strPageCaller=''"> <SCRIPT LANGUAGE="JavaScript">BPB()</SCRIPT>...
6
2658
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a "database frontend" type of intranet application. The existing table-display code consists of a mountain of very clever but extremely brittle spaghetti-javascript, which I'm planning to replace with XSLT transformations. At present I'm still...
3
1689
by: RC | last post by:
Let's say: if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { // Now I got an XML object here var xmlDocument = XMLHttpRequestObject.responseXML; // next I have dealing with XML file tags used DOM. var options = xmlDocument.getElementsByTagNameNS(null,"myXMLTag"); doMyFunctionWithHTMLDOM(options);
4
1895
by: KeithEalanta | last post by:
Hi all, Ive been struggling with a problem for a little, and I can't seem to find any info on it. I am loading an XML file into the browser and that file references an XSLT file as it's default view to be used (e.g. casting the XML data into pretty, formatted XHTML) Is there any way for the resulting document to access the XML that is it's source? (i.e. can I read the XMLs DOM through javascript?) For example if I have an XML-encoded...
0
9727
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10398
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.