P
Pete Verdon
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 prototyping things to make sure that everything I want to do is at
least possible.
The display part of the problem is essentially solved (just a Simple
Matter of (XSLT) Programming(tm)), but editing is a little trickier. The
existing app has in-place editing in all the tables - click a button and
the text in the cells is replaced with (filled) textboxes which can be
edited. This I've done less prototyping on, but believe to be fairly
simple - just run the original XML through a different stylesheet to
produce editing widgets instead of text. The problem comes with saving
the data.
At present, the save can be fairly glitchy, as everything that's changed
has to be kept track of in Javascript. This technique would only get
worse with my plans for new and more sophisticated ways of editing the
data in the page. So what I want to do instead is to generate the "save"
message (already exists, currently generated as an XML string by the
Javascript(!)) by comparing, in XSLT, the original data XML and the
current in-page DOM. Thus any and all changes, whether made by hand
editing or by arbitrarily-complicated Javascript DOM updates, will be
captured, and there is no backing store to get out of sync with what the
user can see. Put the data in the page -> change it -> find the
differences -> transmit them.
As a first stage of prototyping, I've tried putting part of the page DOM
(the contents of a div, originally generated by XSLT as it would be in
the scheme above) through a trivial XSLT transform. This works perfectly
in Firefox (well, except that my XSLT-fu is still a little weak, but
that'll improve ) but fails in IE. As far as I can see, this is
because as far as IE is concerned the contents of the page are not XML
(though they're marked as XHTML; not certain the whole thing is valid
but it's mostly generated by Javascript DOM methods). I tried getting
the innerHTML of the div and using DOMDocument.loadXML to create an XML
document, but even though the div was created by writing to innerHTML
with the results of an XSLT transform in the first place, it seems that
the string is no longer valid when read back out of innerHTML. In
particular (and what kills the parser), attributes are no longer
surrounded by double quotes - nice :-/ . I get the impression that the
MSXML suite is pretty sane and compliant, but any attempt to involve
IE-specific stuff is going to be painful.
So, does anyone know if this scheme is possible in IE? Does anyone know
of a more appropriate place to ask this (my (work) server doesn't seem
to carry MS groups)? And does anyone have a suggestion for a better way
of accomplishing the whole task - this is why I've included so much
background information on what I'm doing. Thanks for any help.
Pete
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 prototyping things to make sure that everything I want to do is at
least possible.
The display part of the problem is essentially solved (just a Simple
Matter of (XSLT) Programming(tm)), but editing is a little trickier. The
existing app has in-place editing in all the tables - click a button and
the text in the cells is replaced with (filled) textboxes which can be
edited. This I've done less prototyping on, but believe to be fairly
simple - just run the original XML through a different stylesheet to
produce editing widgets instead of text. The problem comes with saving
the data.
At present, the save can be fairly glitchy, as everything that's changed
has to be kept track of in Javascript. This technique would only get
worse with my plans for new and more sophisticated ways of editing the
data in the page. So what I want to do instead is to generate the "save"
message (already exists, currently generated as an XML string by the
Javascript(!)) by comparing, in XSLT, the original data XML and the
current in-page DOM. Thus any and all changes, whether made by hand
editing or by arbitrarily-complicated Javascript DOM updates, will be
captured, and there is no backing store to get out of sync with what the
user can see. Put the data in the page -> change it -> find the
differences -> transmit them.
As a first stage of prototyping, I've tried putting part of the page DOM
(the contents of a div, originally generated by XSLT as it would be in
the scheme above) through a trivial XSLT transform. This works perfectly
in Firefox (well, except that my XSLT-fu is still a little weak, but
that'll improve ) but fails in IE. As far as I can see, this is
because as far as IE is concerned the contents of the page are not XML
(though they're marked as XHTML; not certain the whole thing is valid
but it's mostly generated by Javascript DOM methods). I tried getting
the innerHTML of the div and using DOMDocument.loadXML to create an XML
document, but even though the div was created by writing to innerHTML
with the results of an XSLT transform in the first place, it seems that
the string is no longer valid when read back out of innerHTML. In
particular (and what kills the parser), attributes are no longer
surrounded by double quotes - nice :-/ . I get the impression that the
MSXML suite is pretty sane and compliant, but any attempt to involve
IE-specific stuff is going to be painful.
So, does anyone know if this scheme is possible in IE? Does anyone know
of a more appropriate place to ask this (my (work) server doesn't seem
to carry MS groups)? And does anyone have a suggestion for a better way
of accomplishing the whole task - this is why I've included so much
background information on what I'm doing. Thanks for any help.
Pete