473,386 Members | 1,698 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,386 software developers and data experts.

XML and keeping things seperated?

One more question if I may. From what I've gathered, usually you include
the XSLT template right into your main xml doc you're working with,
like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
My question is, is it possible to have the main xml doc in one file
(say, main.xml), but have a seperate xml file for the transformations
(include both a XSLT and the main.xml document.)

From everything I've found online thus far, it seem including xml files
in other xml files isn't a very clear topic, but it seems to me it
should be an essential part if you want to keep things seperate and
organized, unless I'm really missing something here.

Maybe it's just the way I'm used to doing things when programming and
such, but it seems perfectly logical to want to keep the actual xml data
in one place, and have style-related stuff take place outside it, so it
can be styled in multiple fashions, for multiple purposes, like, for
example, have one XLST style sheet for html output, and another for
plain text, and maybe another for man or pod (shell) output. And not
just output, as XSLT can be used to transform into other types of xml
documents, as well as other forms of documents altogether.

Am I correct in surmising that the xslt, in the way it seems to be
normally included in the main xml file you're working with, seems to
have taken this aspect on fro mthe likes of HTML, which normally inlcude
CSS (either externally or inline) in the html file you're working with?
Because for the sheer power XML seems to hold, this doesn't look like
best approuch imho.

Is there a reason they didn't go with a more normalized approuch; that
is, you have your xml source in one file, different stylesheets in other
files, and a 3rd tier files that actually include/use both the xml
source i nquestion, and the stylesheet.

In other words, a structure like the following:

mydata.xml

mydata_style_html.xsl
mydata_style_text.xsl
mydata_style_rss.xsl
mydata_style_foo.xsl
mydata_style_bar.xsl

mydata_output_html.xml
mydata_output_text.xml
mydata_output_rss.xml
mydata_output_foo.xml
mydata_output_bar.xml

In this setup, you have your source in one file, and your style sheets,
each one specifying a different way of display the source data in
mydata.xml.

While it seems to me that while you would be able to, in the "output"
xml files, be able to include a style sheet (ie: <?xml-stylesheet
type="text/xsl" href="mydata_style_html.xsl"?> ), I don't see a way to
include another xml file in a similar way.

What I'm really looking for is something like this, in, say,
`mydata_output_html.xml` :

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-include type="text/xml" href="mydata.xml"?> <!-- <--- (example
only) -->
<?xml-stylesheet type="text/xsl" href="mydata_style_html.xsl"?>

Where that is the only contents of the output file.

Thanks for any insight on this, I'm extreamly curious :-)

--
Stan
Jun 1 '06 #1
6 1163

Stan R. wrote:
One more question if I may. From what I've gathered, usually you include
the XSLT template right into your main xml doc you're working with,
like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
Yes.
My question is, is it possible to have the main xml doc in one file
(say, main.xml), but have a seperate xml file for the transformations
(include both a XSLT and the main.xml document.)


Sort of, but not really how you're thinking.

XML "doesn't do" includes. There are various techniques applicable, but
they're either not workable, not implemented, or just not commonly
used. It's also relatively rare to use the <?xml-stylesheet ... ?> PI.
Most XSLT gets transformed on servers (for widespread output device
compatibility) rather than getting shipped out as XML with a linked
stylesheet and transformed on the final device.

So the linkage of content and presentation stylesheet is (in general)
done by external non-XSLT scripts calling XSLT engines from outside. If
you want to describe this linkage in an XML format then of course you
can do so, but most ways of doing it are project-specific and don't use
a clearly defined or standardisaed format. You can of course use the
PI attached to the document and read this from your script, then use
that to indicate the XSLT transform to use.

You might also find a look at the XInclude protocol and the Cocoon
project to be useful.

Jun 1 '06 #2
Stan R. wrote:
My question is, is it possible to have the main xml doc in one file
(say, main.xml), but have a seperate xml file for the transformations
(include both a XSLT and the main.xml document.)


The example you've shown does exactly that -- the XSLT stylesheet is in
a separate file called test.xsl. (Most likely in the same directory on
the server, since this is a relative URI reference.)

If you want to _specify_ these independently, rather than having the XML
hint which XSLT to use, that can be done too... if your tools support
it. Certainly an explicitly invoked XSLT system can run any stylesheet
against any document. Theoretically, a browser could offer you that same
option of overriding the hint, or could allow a document to specify
several such hints and provide a mechinism allowing the user to pick
among them... but that's a matter of browser features and isn't well
standardized yet.

Welcome to the leading edge. <sigh/>
Jun 1 '06 #3
di*****@codesmiths.com wrote:
Stan R. wrote:
One more question if I may. From what I've gathered, usually you
include the XSLT template right into your main xml doc you're
working with, like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
Yes.
My question is, is it possible to have the main xml doc in one file
(say, main.xml), but have a seperate xml file for the transformations
(include both a XSLT and the main.xml document.)


Sort of, but not really how you're thinking.

XML "doesn't do" includes. There are various techniques applicable,
but they're either not workable, not implemented, or just not commonly
used. It's also relatively rare to use the <?xml-stylesheet ... ?> PI.
Most XSLT gets transformed on servers (for widespread output device
compatibility) rather than getting shipped out as XML with a linked
stylesheet and transformed on the final device.


I wasn't really aware of that, thanks.
So the linkage of content and presentation stylesheet is (in general)
done by external non-XSLT scripts calling XSLT engines from outside.
Are there any common engines, for XSLT, as well as XML checking and
parsing, that are common on linux/UNIX and even win32 ? I think this
part is what really hasn't been clear to me. I am a seasoned programmer,
but xml is something I've very recently started exploring, so I guess
I'm just seeking advise from those in the know, and so far it's helped a
lot :-)
If you want to describe this linkage in an XML format then of course
you can do so, but most ways of doing it are project-specific and
don't use a clearly defined or standardisaed format. You can of
course use the PI attached to the document and read this from your
script, then use that to indicate the XSLT transform to use.
Well if I knew about the engines that can handle the transofrmations
externally, I probably wouldn't of even asked my question, but again,
I'm just exploring something new.
You might also find a look at the XInclude protocol and the Cocoon
project to be useful.


Perhaps, thouhg other posts seem to indicate that is something not
widely supported yet, but may I assume that is something that will be
added to most major parsers, that do not support it, in the near future?

--
Stan
Jun 4 '06 #4
Stan R. wrote:
Are there any common engines, for XSLT, as well as XML checking and
parsing, that are common on linux/UNIX and even win32 ?


I've been involved in Apache Xerces for parsing/validating, and Apache
Xalan for XSLT processing, so I'm biased in those directions. (Actually,
I'm working on a next-generation XSLT processor, but it isn't yet ready
for the general public.)
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 4 '06 #5
Joe Kesselman wrote:
Stan R. wrote:
Are there any common engines, for XSLT, as well as XML checking and
parsing, that are common on linux/UNIX and even win32 ?


I've been involved in Apache Xerces for parsing/validating, and Apache
Xalan for XSLT processing, so I'm biased in those directions.
(Actually, I'm working on a next-generation XSLT processor, but it
isn't yet ready for the general public.)


Can those also be used from the command line?

--
Stan
Jun 4 '06 #6
Stan R. wrote:
Are there any common engines, for XSLT, as well as XML checking and
parsing, that are common on linux/UNIX and even win32 ?

Can those also be used from the command line?


Xalan does have a command-line driver, though it can also be invoked via
an API.

Xerces... well, y'know, parsers are generally used because you want to
read the data into an application rather than because you want to just
parse it and throw it away again. But Xerces does come with a couple of
minimal sample applications that can be run from the command line, and
of course it can be used to implement apps that run from the command line.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 4 '06 #7

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

Similar topics

16
by: Andrew | last post by:
I'm afraid I don't know PHP well enough to figure this out. What I would like is to keep an array in memory so that it doesn't have to be reloaded each time a .php script is run. Is this...
179
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
0
by: Mike Jansen | last post by:
We're doing .NET development for PocketPC, BizTalk, and miscellaneous other things. One of the difficulties has been keeping references to assemblies intact in a project when the referenced...
0
by: NSD | last post by:
Which Oracle program to use for adminitration and book-keeping Hello there, I am new to Oracle and I need to know how I can insert my company's data (administration and book - keeping) into an...
2
nehashri
by: nehashri | last post by:
i hv a database in access wid Asp as front end. ven given a word in search command(of the front end) it shud go to a table in which each field has words serated by comma. each word shud b checked...
4
nehashri
by: nehashri | last post by:
i want to knw how Search for text within single file in Ms Access, i have my data seperated by commas in the columns....... how do i query through the file for single word. like for example i want...
0
by: Kristi | last post by:
I need to create a CL program that will take a PF, and create a tab delimited file that has comma seperated column headings as the first record. I know i can use cpytostmf/cpytoimpf to create the...
4
by: Marina Levit | last post by:
I am trying to do some processing on a background thread while keeping the UI painting. However, this is a generic server side call routine - and it needs to block until the server side call...
0
by: jehugaleahsa | last post by:
On Jun 13, 3:09 pm, "Bob Powell " <b...@spamkillerbobpowell.net> wrote: I apologize for the size. I should have probably put this on a blog or something. I'm not interested in tools. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.