473,394 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Viewing one XML using multiple XSL files

I started learning XML on Monday.

I have an XML file and have written an XSL file to render it to HTML for
formatted viewing in a browser. I'd like to create a second alternative
view of the same data. I am confused how:

If the following line, which dictates which XSL file should be
used to transform my XML document for me, is found *in the XML file
itself* then how can you use more than one XSL to present multiple views
of the same XML document?

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>

Am I approaching this the wrong way?

--
-Toby
Add the word afiduluminag to the subject to circumvent my email filters.
Jan 25 '07 #1
13 9602
Toby Newman wrote:
If the following line, which dictates which XSL file should be
used to transform my XML document for me, is found *in the XML file
itself* then how can you use more than one XSL to present multiple views
of the same XML document?

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>
The xml-stylesheet processing instruction is modelled after the HTML
link element so it should allow you (in theory) to have several such
processing instructions to suggest alternative stylesheets.
However in reality for XSLT stylesheet I don't think any of the major
desktop browsers like IE 6 and later, Mozilla/Firefox or Opera support that.
On the other hand such a processing instruction does not prevent you to
use script and an XSLT processor API on the server to apply different
stylesheet as you like or want.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 25 '07 #2
On 2007-01-25, Martin Honnen <ma*******@yahoo.dewrote:
Toby Newman wrote:
>If the following line, which dictates which XSL file should be
used to transform my XML document for me, is found *in the XML file
itself* then how can you use more than one XSL to present multiple views
of the same XML document?

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>

The xml-stylesheet processing instruction is modelled after the HTML
link element so it should allow you (in theory) to have several such
processing instructions to suggest alternative stylesheets.
However in reality for XSLT stylesheet I don't think any of the major
desktop browsers like IE 6 and later, Mozilla/Firefox or Opera support that.
On the other hand such a processing instruction does not prevent you to
use script and an XSLT processor API on the server to apply different
stylesheet as you like or want.
Would it be possible to encode the filename of the XSL that I want to
use in the URL?
Like this:

http://www.domain.com/myxml.xml?XSLT=viewOne.xsl
http://www.domain.com/myxml.xml?XSLT=viewTwo.xsl

I've done this before in PHP and know how to get the variables from the
URL using PHP. I'm not using PHP files now, though, I'm using XML files.
XML files aren't server-side scripted, though, so can I fetch the
variable somehow in from the URL within XML?

--
-Toby
500 Nintendo Stars for trade: 2xWii Play
* * * * * * * * * * * * * * * * * * * * * * *
Add the word afiduluminag to the subject to circumvent my email filters.
Jan 25 '07 #3
Toby Newman wrote:
Would it be possible to encode the filename of the XSL that I want to
use in the URL?
Like this:

http://www.domain.com/myxml.xml?XSLT=viewOne.xsl
http://www.domain.com/myxml.xml?XSLT=viewTwo.xsl

I've done this before in PHP and know how to get the variables from the
URL using PHP. I'm not using PHP files now, though, I'm using XML files.
XML files aren't server-side scripted, though, so can I fetch the
variable somehow in from the URL within XML?
You need server-side scripting reading out the query string and running
the transformation e.g.
http://example.com/transform.php?xml...lt=viewOne.xsl
then transform.php reads out the file names, runs the transformation and
sends the transformation result to the client.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 25 '07 #4
On 2007-01-25, Martin Honnen <ma*******@yahoo.dewrote:
Toby Newman wrote:
>Would it be possible to encode the filename of the XSL that I want to
use in the URL?
Like this:

http://www.domain.com/myxml.xml?XSLT=viewOne.xsl
http://www.domain.com/myxml.xml?XSLT=viewTwo.xsl

I've done this before in PHP and know how to get the variables from the
URL using PHP. I'm not using PHP files now, though, I'm using XML files.
XML files aren't server-side scripted, though, so can I fetch the
variable somehow in from the URL within XML?

You need server-side scripting reading out the query string and running
the transformation e.g.
http://example.com/transform.php?xml...lt=viewOne.xsl
then transform.php reads out the file names, runs the transformation and
sends the transformation result to the client.
Ack - that's a shame. I don't have PHP or ASP on the server I'm using -
it's a Sharepoint server and ASP is blocked. Is there any other way?

--
-Toby
500 Nintendo Stars for trade: 2xWii Play
* * * * * * * * * * * * * * * * * * * * * * *
Add the word afiduluminag to the subject to circumvent my email filters.
Jan 25 '07 #5
In article <45***********************@newsspool2.arcor-online.net>,
ma*******@yahoo.de says...
You need server-side scripting reading out the query string and running
the transformation e.g.
http://example.com/transform.php?xml...lt=viewOne.xsl
then transform.php reads out the file names, runs the transformation and
sends the transformation result to the client.
Curiosity Question:
So, does this mean that the script needs to read the XML file and make
changes to it before sending it to the browser? Is this what is commonly
meant when you say "transform"?

If that is so, then couldn't one write javascript code that reads the XML
file from wherever it is on the internet and converts (transforms) that
one line to whatever is needed then sends the rest on to the browser? I
know diddly about javascript, but from what I have gathered it can read
files from the internet and it can send HTML to the browser so that the
browser acts as if it just read it directly off of the web site. So, if
the javascript fed the browser an XML file with that one line modified
would the browser then act as if it just read that XML file directly off
of a web site and then do the XSL transformation itself?

Naturally, that would slow down the display because the XML file was
being processed twice but it might work.

Perhaps one could even embed the XML file permanently into the javascript
code. Then the XML would be transmitted at the same time as the
javascript code and would already be on the client's computer. This would
be like writing a program to display a page of text by simply writing a
bunch of cout statements (C++) rather than simply saving and opening the
text file. Naturally, the down side to this is that you no longer have a
true XML file that can be parsed. Maybe you could also write a little
utility that would automatically embed any XML file you wanted into a
similar javascript program to make it easy to generate these javascript
programs. But now I am making it way too complicated.
Jan 26 '07 #6
Grant Robertson wrote:
In article <45***********************@newsspool2.arcor-online.net>,
ma*******@yahoo.de says...
>You need server-side scripting reading out the query string and running
the transformation e.g.
http://example.com/transform.php?xml...lt=viewOne.xsl
then transform.php reads out the file names, runs the transformation and
sends the transformation result to the client.

Curiosity Question:
So, does this mean that the script needs to read the XML file and make
changes to it before sending it to the browser? Is this what is commonly
meant when you say "transform"?
With transform I am talking about XSLT transformations, usually in the
context of the web XML is being transformed with an XSLT stylesheet to
HTML as that is what browsers can render.
If that is so, then couldn't one write javascript code that reads the XML
file from wherever it is on the internet and converts (transforms) that
one line to whatever is needed then sends the rest on to the browser? I
know diddly about javascript, but from what I have gathered it can read
files from the internet and it can send HTML to the browser so that the
browser acts as if it just read it directly off of the web site. So, if
the javascript fed the browser an XML file with that one line modified
would the browser then act as if it just read that XML file directly off
of a web site and then do the XSL transformation itself?
If you have ASP/J(ava)Script on the server then you can run the XSLT
transformation on the server (PHP was only mentioned as an example). It
would also be possible to simply change the xml-stylesheet processing
instruction and send the XML to the client but relying on client-side
XSLT support if the transformation can be done on the server does not
necessarily sound like a good idea.
However the original already pointed out that he does not have ASP on
his server.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 26 '07 #7
In article <45**********************@newsspool3.arcor-online.net>,
ma*******@yahoo.de says...
With transform I am talking about XSLT transformations, usually in the
context of the web XML is being transformed with an XSLT stylesheet to
HTML as that is what browsers can render.
Can't a browser open a raw XML file and apply the XSL itself? Or is XSL
different enough from XSLT that I am totally off base? When I open some
XML files with my browser I get a little bit of formatting over and above
just what a text file gets. But when I open some XML files I get a
message that says that there was no XSL file specified so the browser
just applied a default style.

Does XSLT perform transformations that can only be done on a server and
then send out the HTML to the browser or is it possible for a browser to
perform the transformations itself? I'm guessing older browsers couldn't
do it but could newer ones?
Jan 26 '07 #8
Grant Robertson wrote:
Can't a browser open a raw XML file and apply the XSL itself?
Yes, a good browser really should be able to do so; that was sorta the
original design point for stylesheets generally. I'm not sure which
browsers can do it these days; I've mostly been running stand-alone XSLT
engines.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Jan 26 '07 #9
Martin Honnen <ma*******@yahoo.dewrites:
Toby Newman wrote:
>If the following line, which dictates which XSL file should be
used to transform my XML document for me, is found *in the XML file
itself* then how can you use more than one XSL to present multiple views
of the same XML document?

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>

The xml-stylesheet processing instruction is modelled after the HTML
link element so it should allow you (in theory) to have several such
processing instructions to suggest alternative stylesheets.
However in reality for XSLT stylesheet I don't think any of the major
desktop browsers like IE 6 and later, Mozilla/Firefox or Opera support
that.
On the other hand such a processing instruction does not prevent you
to use script and an XSLT processor API on the server to apply
different stylesheet as you like or want.
In some cases using trivial xml file for tying xsl and xml may help.

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>
<xml-file href="myXML.xml" />

It will require your myXSL.xsl style-sheet to process myXML.xml file when
processing xml-file.
--
[pl>en: Andrew] Andrzej Adam Filip : an**@priv.onet.pl : an**@xl.wp.pl
Home site: http://anfi.homeunix.net/
Jan 27 '07 #10
Grant Robertson wrote:
Can't a browser open a raw XML file and apply the XSL itself?
Yes, but the original question is that someone wants to offer several
different stylesheet for an XML document. To that question I did reply
that the xml-stylesheet processsing instruction in theory allows that
but that browsers in pratice do not support that. You seem to have
missed that original problem.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 27 '07 #11
In article <45***********************@newsspool4.arcor-online.net>,
ma*******@yahoo.de says...
You seem to have
missed that original problem.

Nah. I hyjacked the thread again. Sometimes the answers to the original
question peaks my interest about something related. I did preface my
question with "Curiosity Question:". I guess I should have changed the
subject line as well. Would people here prefer that I start an entirely
new thread also? In most of usenet people have gotten so lax that I often
don't go to the full effort of full netiquette any more.
Jan 27 '07 #12
On 2007-01-27, Andrzej Adam Filip <an**@onet.euwrote:
Martin Honnen <ma*******@yahoo.dewrites:
>Toby Newman wrote:
>>If the following line, which dictates which XSL file should be
used to transform my XML document for me, is found *in the XML file
itself* then how can you use more than one XSL to present multiple views
of the same XML document?

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>

The xml-stylesheet processing instruction is modelled after the HTML
link element so it should allow you (in theory) to have several such
processing instructions to suggest alternative stylesheets.
However in reality for XSLT stylesheet I don't think any of the major
desktop browsers like IE 6 and later, Mozilla/Firefox or Opera support
that.
On the other hand such a processing instruction does not prevent you
to use script and an XSLT processor API on the server to apply
different stylesheet as you like or want.

In some cases using trivial xml file for tying xsl and xml may help.

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>
<xml-file href="myXML.xml" />

It will require your myXSL.xsl style-sheet to process myXML.xml file when
processing xml-file.
I'm a little unsure what you mean. Is this something I could do without
server-side scripting?
--
-Toby
500 Nintendo Stars for trade: 2xWii Play
* * * * * * * * * * * * * * * * * * * * * * *
Add the word afiduluminag to the subject to circumvent my email filters.
Jan 29 '07 #13
Toby Newman <go****@asktoby.comwrites:
On 2007-01-27, Andrzej Adam Filip <an**@onet.euwrote:
>Martin Honnen <ma*******@yahoo.dewrites:
>>Toby Newman wrote:

If the following line, which dictates which XSL file should be
used to transform my XML document for me, is found *in the XML file
itself* then how can you use more than one XSL to present multiple views
of the same XML document?

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>

The xml-stylesheet processing instruction is modelled after the HTML
link element so it should allow you (in theory) to have several such
processing instructions to suggest alternative stylesheets.
However in reality for XSLT stylesheet I don't think any of the major
desktop browsers like IE 6 and later, Mozilla/Firefox or Opera support
that.
On the other hand such a processing instruction does not prevent you
to use script and an XSLT processor API on the server to apply
different stylesheet as you like or want.

In some cases using trivial xml file for tying xsl and xml may help.

<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>
<xml-file href="myXML.xml" />

It will require your myXSL.xsl style-sheet to process myXML.xml file when
processing xml-file.

I'm a little unsure what you mean. Is this something I could do without
server-side scripting?
xsl script/file can "parse" additional xml files except xml file with
xml-stylesheet so you can "reference" in your xml file additional xml
files for processing by your xsl using document function.

http://www.w3.org/TR/xslt#document
<quote>
12.1 Multiple Source Documents
Function: node-set document(object, node-set?)
The document function allows access to XML documents other than the
main source document.
</quote>

WARNING: I have not test how it is supported by "main browsers".

--
[pl>en: Andrew] Andrzej Adam Filip : an**@priv.onet.pl : an**@xl.wp.pl
Home site: http://anfi.homeunix.net/
Jan 29 '07 #14

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

Similar topics

3
by: yogesh | last post by:
How to store the java applet emebedded in a web page for offline viewing? I saved the web page but it got saved without the applet.and also I searched for the corressponding .class file for the...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
5
by: aolson | last post by:
First of all i am pretty new to VB .NET as a whole so my answer may be silly as may my questions. Here is what i would like to do. I would like to open potentially multiple word documents for...
10
by: David Lee Conley | last post by:
When I open the Data Sources window and create a new data source, everything works fine. But if I have a form showing in the IDE, the Data Sources window becomes disabled and doesn't display any...
8
by: Sheldon | last post by:
I just received a 2nd (configured as a dual) monitor but, for Access only, I can't seem to figure out, if it's possible, to view, say, Table1 on one monitor and Table2 on the other monitor. If I...
14
by: kmpathy | last post by:
I am new Sql Plus Want to know the command for viewing databases avaialble using default password and username on my co. server.. (example : dir command for viewing files) help me.
1
by: =?Utf-8?B?TWFuaQ==?= | last post by:
I am using vista home premium. I am a new computer user. I could not view files in a CD/DVD. When i use the same CD in another computer with XP there is no problem in viewing the picture files. ...
1
by: raul15791 | last post by:
Hi, I'm newbie in ASP. I am trying to view multiple pages by using a single file. For example, I have a few pages of product.asp (products.asp, products1.asp and so on). Now I want to create a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.