[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] how to view html not xml/xsl?


Subject: Re: [xsl] how to view html not xml/xsl?
From: Steve Rosenberry <Steve.Rosenberry@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Jun 2003 15:50:42 -0400


Kathy Burke wrote:
> 
> How can I see the actual html transformation and not the xml (view source
> shows only the xml). Set to be output="html".
> 

I'm interpolating here by assuming your using an IE browser to display
the transformed XML.  If so, the only way I know to see the actual
transformed HTML is through some Javascript magic using the following
two functions:

// handle opening or reusing an already open display window
displayWin = null;
function showDisplayWin( title )
{

    if( typeof displayWin == "undefined" || displayWin == null ||
displayWin.closed )
    {
      displayWin = window.open( "about:blank", "DisplayWindow", 
                                "resizable=yes,scrollbars=yes" );
      displayWin.document.write( "<html><title>HTML</title>" + 
                                 "<body style=\"font:x-small
'Verdana';\">" + 
                                 "<nobr
id=x>working...</nobr></body></html>\n" );
    }
    else
      displayWin.document.body.all("x").innerText = "working...";

    displayWin.document.title = title;

    displayWin.focus();

}

// Javascript function to place the transformed HTML in a 
// separate display window
function display_html( )
{

    // open or locate an already open second display window
    showDisplayWin( "HTML" );

    // get the XML document
    xmlDoc = document.XMLDocument;

    // get the stylesheet as assigned in the XML document
    stylesheet = document.XSLDocument;  

    // get the root node (you may find better ways of doing this
    // depending upon your situation)
    node = xmlDoc.getElementsByTagName( 'YourXMLRootNodeName' )[0];

    // transform the XML using the stylesheet
    output_text = node.transformNode( stylesheet );

    // update the display window to show transformed HTML 
    // as actual HTML
    displayWin.document.body.all("x").innerText = output_text;

}


You have two methods to tie the Javascript to a page:

1) Place a temporary input button on the page itself:
     <input type="button" value="Display HTML" onclick="display_html()"
/>
   Of course, this assumes you can get to the point where something
actually 
   displays in the browser window.

2) Tie the above Javascript to an item in IE's context menu (right mouse
button click).  It's not terribly difficult but does require editing the
registry.  More details can be found starting at:

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/tutorials/context.asp



Hope this helps...



-- 
Steve Rosenberry
Sr. Partner

Electronic Solutions Company -- For the Home of Integration
http://ElectronicSolutionsCo.com

(610) 670-1710

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xml