how to apply different XSL sheets?
I have an XML document that references an XSL template for presentation in
the browser. Works great !
But, the question is...
How would you conditionally apply different XSL templates based on the
application? You would not dynamically recreate the XML since that document
could be huge. Is the only option to dynamically create the referenced XSL
template? Is there an easier way of accomplishing this?
Thanks in Advance,
Phil
# 1 Re: how to apply different XSL sheets?
I dont understand ur problem fully, but if im right, ur asking about conditionally
applying two(or more) xsl files on a single xml. right? that can be accomplished
by keeping a DOM object globally on ur page, holding the XML data, and on
different hyperlinks/other actions (conditions), load the specific xsl DOM
and TransformNode() your XML DOM.
Rohit
>How would you conditionally apply different XSL templates based on the application?
You would not dynamically recreate the XML since that document
>could be huge. Is the only option to dynamically create the referenced XSL
>template? Is there an easier way of accomplishing this?
# 2 Re: how to apply different XSL sheets?
Rohit,
Thanks for the response.
Let's say I have an XML document that contains data of my clients addresses
and phone numbers, etc...If I login through my desktop web browser, I want
the data formatted one way. If I connect through a wireless device, I want
it formatted in a different way. I want to use the same XML document as my
data source. Since the XML usually contains a line like...
<?xml-stylesheet type="text/xsl" href="clients_xsl.xml" ?>
...in order to link in an XSL stylesheet...how do I handle the different
formating requests?
Phil
Rohit Wason <rohitw@futuresoftindia.com> wrote in message
news:3907cd80$1@news.dev-archive.com...
>
> I dont understand ur problem fully, but if im right, ur asking about
conditionally
> applying two(or more) xsl files on a single xml. right? that can be
accomplished
> by keeping a DOM object globally on ur page, holding the XML data, and on
> different hyperlinks/other actions (conditions), load the specific xsl DOM
> and TransformNode() your XML DOM.
> Rohit
>
>
>
> >How would you conditionally apply different XSL templates based on the
application?
> You would not dynamically recreate the XML since that document
> >could be huge. Is the only option to dynamically create the referenced
XSL
> >template? Is there an easier way of accomplishing this?
# 3 Re: how to apply different XSL sheets?
Phil,
I'm sorry, if I didn't make myself clear enough in that response.
The scenario, which you talk about, is where we specify the xsl to be used
to render the xml. in the xml itself.
but in ur case, if you want to "render" the xml differently in different
conditions, you need to use XMLDOM object model in ur page itself, which
has a <DIV> layer to be filled with the o/p
<SCRIPT>
<!--
var xmldoc; //populated in the body_onload()
function render(xslfile){
var xsl = new ActiveXObject("Microsoft.XMLDOM");
xsl.load(xslfile);
document.all("lyrOP").innerHTML = xml.TransformNode(xsl);
}
//-->
</SCRIPT>
<BODY
onLoad="xmldoc=new ActiveXObject('Microsoft.XMLDOM');
xml.load('http://mysite.com/mydata.xml');render('http://mysite.com/one.xsl');">
<DIV id="lyrOP" name="lyrOP"></DIV>
</BODY>
This is the small bit of effort required at the client side script. and of
course this is MS-specific. Typically, this xml will not have the <?xml-stylesheet...>
tag, you talk about. And the call to this html can be accompanied by a querysrting
comprising of the xsl file you want to open it with.
So your scene of Desktop based call may look like
"http://mysite/mypage.html?one.xsl"
and one for the wireless device may look like
"http://mysite/mypage.html?two.xsl"
right?
Rohit
# 4 Re: how to apply different XSL sheets?
Rohit,
Thank you very much for your response.
This is just what I was looking for.
Phil
Rohit Wason <rohitw@futuresoftindia.com> wrote in message
news:3909157b$2@news.dev-archive.com...
>
> Phil,
>
> I'm sorry, if I didn't make myself clear enough in that response.
> The scenario, which you talk about, is where we specify the xsl to be used
> to render the xml. in the xml itself.
>
> but in ur case, if you want to "render" the xml differently in different
> conditions, you need to use XMLDOM object model in ur page itself, which
> has a <DIV> layer to be filled with the o/p
>
> <SCRIPT>
> <!--
> var xmldoc; file://populated in the body_onload()
> function render(xslfile){
> var xsl = new ActiveXObject("Microsoft.XMLDOM");
> xsl.load(xslfile);
> document.all("lyrOP").innerHTML = xml.TransformNode(xsl);
> }
> file://-->
> </SCRIPT>
> <BODY
> onLoad="xmldoc=new ActiveXObject('Microsoft.XMLDOM');
>
xml.load('http://mysite.com/mydata.xml');render('http://mysite.com/one.xsl')
;">
>
> <DIV id="lyrOP" name="lyrOP"></DIV>
>
> </BODY>
>
> This is the small bit of effort required at the client side script. and of
> course this is MS-specific. Typically, this xml will not have the
<?xml-stylesheet...>
> tag, you talk about. And the call to this html can be accompanied by a
querysrting
> comprising of the xsl file you want to open it with.
>
> So your scene of Desktop based call may look like
> "http://mysite/mypage.html?one.xsl"
>
> and one for the wireless device may look like
> "http://mysite/mypage.html?two.xsl"
>
> right?
> Rohit
# 5 Re: how to apply different XSL sheets?
Philip,
Maybe make the xsl file an ASP page?
It could return the correct XSL dependent on the browser...
Greg Longtin