|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: RE: Displaying XML source with XSL
>From Microsoft Reference material on "Direct XML
Browsing in IE5" I see:
| When using an XSL style sheet, you can access the
| XML source through the XML Document Object Model
| (DOM). Two additional properties are exposed on
| the document object from DHTML:
|
| document.XMLDocument
| document.XSLDocument
|
| The XMLDocument property returns the root of the
| XML source tree, and the XSLDocument property
| returns the root of the XSL style sheet.
I created a two-frame frameset and loaded used IE5
to directly browse an XML file in one frame while
some Script in the other frame wrote the value of:
parent.leftframe.document.XSLDocument.xml
to a text file.
I slightly modified the CSS styles to make the
font 18pt instead of 10pt (the default) for some
demos I was doing in a large room, but other than
that the default style sheet looks like what's
below. A little cryptic, but a definitely
learning tool.
Have fun.
<?xml version="1.0" ?>
<x:template xmlns:x="uri:xsl"><HTML><HEAD>
<STYLE>BODY{font:18pt Verdana}
.c{cursor:hand}
.b{color:red;font-family:FixedSys}
.e{margin-left:1em;text-indent:-1em;margin-bottom:3px}
.k{margin-left:1em;text-indent:-1em;margin-bottom:3px}
.t{color:#444444}
.a{color:#444444}
.tx{font-weight:bold;color:blue}
.db{text-indent:0px;margin-left:2em;margin-top:0px;margin-bottom:0px;font:18pt
Courier;color:#0044BB}
.di{font:18pt Courier;color:#0044BB}
.d{color:#0044BB}
.pi{color:#0044BB}
.cb{text-indent:0px;margin-left:2em;margin-top:0px;margin-bottom:0px;font:18pt
Courier;color:#0044BB}
.ci{font:18pt Courier;color:#0044BB}
PRE{margin:0px;display:inline}</STYLE>
<SCRIPT>
<x:comment>
function initState(){
var pres=document.all.tags("PRE");
for (var i=0;i<pres.length;i++){
var cparent=pres(i).parentElement;
if (cparent.className=="ci"){
if (cparent.children(0).innerText.indexOf("\n")>0){
cparent.className="cb";
cparent.style.display="block";
cparent.parentElement.children(0).className="c";
cparent.parentElement.children(0).children(0).innerText="-";
}}
if (cparent.className=="di"){
if (cparent.children(0).innerText.indexOf("\n")>0){
cparent.className="db";
cparent.style.display="block";
cparent.parentElement.children(0).className="c";
cparent.parentElement.children(0).children(0).innerText="-";
}}}}
function changeState(e){
mark=e.children(0).children(0);
if (mark.innerText=="+"){
for (var i=1;i<e.children.length;i++)
e.children(i).style.display="block";
mark.innerText="-";}
else if (mark.innerText=="-"){
for (var i=1;i<e.children.length;i++)
e.children(i).style.display="none";
mark.innerText="+";
}}
function changeChunkState(e){
mark=e.children(0).children(0);
contents=e.children(1);
if (mark.innerText=="+"){
if (contents.className=="db"||contents.className=="cb")
contents.style.display="block";
else
contents.style.display="inline";
mark.innerText="-";}
else if (mark.innerText=="-"){
contents.style.display="none";
mark.innerText="+";
}}
function document_click(){
e=window.event.srcElement;
if (e.className!="c"){e=e.parentElement;if (e.className!="c"){return;}}
e=e.parentElement;
if (e.className=="e") changeState(e);
if (e.className=="k") changeChunkState(e);
}
document.onclick=document_click;
</x:comment></SCRIPT>
<SCRIPT FOR="window"
EVENT="onload">initState();</SCRIPT>
</HEAD>
<BODY class="st"><x:use-templates for="."/></BODY>
</HTML>
<x:define-template-set>
<x:template><x:use-templates/></x:template>
<x:template match="node()[nodeType()=10]">
<DIV class="e"><SPAN>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN class="d"><!DOCTYPE
<x:nodeName/><SPAN STYLE="font-style:italic"> (View Source for full
doctype...)</SPAN>></SPAN>
</SPAN></DIV>
</x:template>
<x:template match="pi()">
<DIV class="e"><DIV>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN class="pi"><?<x:nodeName/>
<x:value-of/>?></SPAN>
</DIV></DIV>
</x:template>
<x:template match="pi('xml')">
<DIV class="e"><DIV>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN class="pi"><?<x:nodeName/>
<x:for-each
select="@*"><x:nodeName/>="<x:value-of/>" </x:for-each>?></SPAN>
</DIV></DIV>
</x:template>
<x:template match="@*"><SPAN class="a">
<x:nodeName/>="</SPAN><x:value-of/><SPAN
class="a">"</SPAN></x:template>
<x:template match="textnode()">
<DIV class="e"><DIV>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN class="tx"><x:value-of/></SPAN>
</DIV></DIV>
</x:template>
<x:template match="comment()">
<DIV class="k"><SPAN>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN
class="t"><!--</SPAN></SPAN><SPAN class="ci"><PRE><x:value-of/></PRE></SPAN>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN class="t">--></SPAN>
</DIV>
</x:template>
<x:template match="cdata()">
<DIV class="k"><SPAN>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN
class="t"><![CDATA[</SPAN></SPAN><SPAN
class="di"><PRE><x:value-of/></PRE></SPAN>
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN class="t">]]></SPAN>
</DIV>
</x:template>
<x:template match="*">
<DIV class="e">
<DIV><SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN
class="t"><<x:nodeName/></SPAN>
<x:apply-templates select="@*"/>
<SPAN class="t">/></SPAN>
</DIV></DIV>
</x:template>
<x:template match="*[node()]">
<DIV class="e"><DIV class="c">
<SPAN class="b">-</SPAN>
<SPAN
class="t"><<x:nodeName/></SPAN><x:apply-templates select="@*"/>
<SPAN class="t">></SPAN>
</DIV>
<x:use-templates/>
<SPAN class="t">
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
</<x:nodeName/>></SPAN>
</DIV>
</x:template>
<x:template match="*[textnode()]">
<DIV class="e">
<DIV STYLE="margin-left:1em;text-indent:-2em">
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN
class="t"><<x:nodeName/></SPAN><x:apply-templates select="@*"/>
<SPAN class="t">></SPAN><SPAN
class="tx"><x:value-of/></SPAN><SPAN class="t"></<x:nodeName/>></SPAN>
</DIV></DIV>
</x:template>
<x:template match="*[*]">
<DIV class="e">
<DIV class="c"><SPAN class="b">-</SPAN>
<SPAN
class="t"><<x:nodeName/></SPAN><x:apply-templates select="@*"/>
<SPAN class="t">></SPAN></DIV>
<x:use-templates/>
<SPAN class="t"><SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
</<x:nodeName/>></SPAN>
</DIV>
</x:template>
<x:template match="*[*$and$textnode()$and$$not$*/*]">
<DIV class="e"><DIV
STYLE="margin-left:1em;text-indent:-2em">
<SPAN class="b"><x:entityref
name="nbsp"/></SPAN>
<SPAN
class="t"><<x:nodeName/></SPAN><x:apply-templates select="@*"/><SPAN
class="t">></SPAN><x:use-templates>
<x:template
match="textnode()"><SPAN class="tx"><x:value-of/></SPAN></x:template>
<x:template match="*">
<SPAN
class="t"><<x:nodeName/></SPAN><x:apply-templates select="@*"/>
<SPAN
class="t">></SPAN><x:use-templates/><SPAN
class="t"></<x:nodeName/>></SPAN></x:template>
</x:use-templates><SPAN
class="t"></<x:nodeName/>></SPAN>
</DIV></DIV>
</x:template>
</x:define-template-set>
</x:template>
_______________________________________________
Steve Muench, Consulting PM & XML Evangelist
Java Business Objects Dev't Team
smuench@xxxxxxxxxx -- http://www.oracle.com/xml
--- Begin Message ---
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








