473,789 Members | 2,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I've read up on XML, but how to really use it??

Hi. I'm an old programmer whose been finally reading up on xml the past
week. The concepts of xml, dtd, and xsl seem pretty straight forward to
me. I understand that xsl (as xslt for transformations ) can be used to
transform xml data from an xml document into another document, as
specified in the templates.

One of the best examples I've seen by far is transforming a given xml
doc into html.

But where I seem to be getting stuck in the mud is how to really apply
xml documents. I know they can be used as data holders and config files
for regular applications. But how do you use it more directly, to, say,
generate a webpage from an xml doc.

Also (and this is kind of what I'm really getting at) is, is it possible
to write web pages, so to speak, using xml and xslt. I noticed that such
applications like Front Page 2003 (I sometimes use it as my html editor)
let you make xml documents.

From what I can see, I can easily make an .xml, .dtd, and .xslt files in
a folder somewhere in the document root on my web server, but what I
TRULY don't understand is how do I actually "call" the xslt (since it
does the actual transformation) from the web browser? Does it need to be
"called" from an html document, or what? This is what I'm most confused
on, and thanks for any help clearing up the waters.

(Also, any good real world examples for an xml+dtd+xslt would be helpful
too.)

--
Stan
May 30 '06 #1
10 1559
Stan R. wrote:
Hi. I'm an old programmer whose been finally reading up on xml the past
week. The concepts of xml, dtd, and xsl seem pretty straight forward to
me. I understand that xsl (as xslt for transformations ) can be used to
transform xml data from an xml document into another document, as
specified in the templates.

One of the best examples I've seen by far is transforming a given xml
doc into html.
The power of xsl lies in the fact that it can be used to transform any
xml file into any other xml file.

But where I seem to be getting stuck in the mud is how to really apply
xml documents. I know they can be used as data holders and config files
for regular applications. But how do you use it more directly, to, say,
generate a webpage from an xml doc.

Also (and this is kind of what I'm really getting at) is, is it possible
to write web pages, so to speak, using xml and xslt. I noticed that such
applications like Front Page 2003 (I sometimes use it as my html editor)
let you make xml documents.

You cannot write to web pages(atleast without any programming support),
but you can make the browser to create html output on the fly using
xsl.
From what I can see, I can easily make an .xml, .dtd, and .xslt files in
a folder somewhere in the document root on my web server, but what I
TRULY don't understand is how do I actually "call" the xslt (since it
does the actual transformation) from the web browser? Does it need to be
"called" from an html document, or what? This is what I'm most confused
on, and thanks for any help clearing up the waters.


You dont call the xsl from the browser. A simple directive in the
beginning of the xml file will tell the browser which xsl stylesheet
file to apply.

For a clearer example see
http://www.captain.at/howto-xml-xsl-example.php

-Dhanvanth

May 30 '06 #2
Stan R. wrote:
Hi. I'm an old programmer whose been finally reading up on xml the past
week. The concepts of xml, dtd, and xsl seem pretty straight forward to
me. I understand that xsl (as xslt for transformations ) can be used to
transform xml data from an xml document into another document, as
specified in the templates.

One of the best examples I've seen by far is transforming a given xml
doc into html.

But where I seem to be getting stuck in the mud is how to really apply
xml documents. I know they can be used as data holders and config files
for regular applications. But how do you use it more directly, to, say,
generate a webpage from an xml doc.
You can write an XSLT transformation to do this, as you already mention
in the previous paragraph.
Also (and this is kind of what I'm really getting at) is, is it possible
to write web pages, so to speak, using xml and xslt. I noticed that such
applications like Front Page 2003 (I sometimes use it as my html editor)
let you make xml documents.
It's possible, but support for in-browser XML and XSLT is patchy.
Server-side transformation is strongly recommended.
From what I can see, I can easily make an .xml, .dtd, and .xslt files in
a folder somewhere in the document root on my web server, but what I
TRULY don't understand is how do I actually "call" the xslt (since it
does the actual transformation) from the web browser?
See the FAQ: http://xml.silmaril.ie/authors/style/
Does it need to be
"called" from an html document, or what? This is what I'm most confused
on, and thanks for any help clearing up the waters.
The stylesheet has to be referenced in the XML document. The browser
fetches it and applies it to perform the transformation.
(Also, any good real world examples for an xml+dtd+xslt would be helpful
too.)
See the links in the FAQ (it's all done that way).
http://xml.silmaril.ie/admin/availability/

///Peter

May 30 '06 #3
dh*******@gmail .com wrote:
Stan R. wrote:
Hi. I'm an old programmer whose been finally reading up on xml the
past week. The concepts of xml, dtd, and xsl seem pretty straight
forward to me. I understand that xsl (as xslt for transformations )
can be used to transform xml data from an xml document into another
document, as specified in the templates.

One of the best examples I've seen by far is transforming a given xml
doc into html.


The power of xsl lies in the fact that it can be used to transform any
xml file into any other xml file.

But where I seem to be getting stuck in the mud is how to really
apply xml documents. I know they can be used as data holders and
config files for regular applications. But how do you use it more
directly, to, say, generate a webpage from an xml doc.

Also (and this is kind of what I'm really getting at) is, is it
possible to write web pages, so to speak, using xml and xslt. I
noticed that such applications like Front Page 2003 (I sometimes use
it as my html editor) let you make xml documents.

You cannot write to web pages(atleast without any programming
support), but you can make the browser to create html output on the
fly using xsl.
From what I can see, I can easily make an .xml, .dtd, and .xslt
files in a folder somewhere in the document root on my web server,
but what I TRULY don't understand is how do I actually "call" the
xslt (since it does the actual transformation) from the web browser?
Does it need to be "called" from an html document, or what? This is
what I'm most confused on, and thanks for any help clearing up the
waters.


You dont call the xsl from the browser. A simple directive in the
beginning of the xml file will tell the browser which xsl stylesheet
file to apply.

For a clearer example see
http://www.captain.at/howto-xml-xsl-example.php


Thank you very much.

--
Stan
May 31 '06 #4
Peter Flynn wrote:
Stan R. wrote:
Hi. I'm an old programmer whose been finally reading up on xml the
past week. The concepts of xml, dtd, and xsl seem pretty straight
forward to me. I understand that xsl (as xslt for transformations )
can be used to transform xml data from an xml document into another
document, as specified in the templates.

One of the best examples I've seen by far is transforming a given xml
doc into html.

But where I seem to be getting stuck in the mud is how to really
apply xml documents. I know they can be used as data holders and
config files for regular applications. But how do you use it more
directly, to, say, generate a webpage from an xml doc.


You can write an XSLT transformation to do this, as you already
mention in the previous paragraph.
Also (and this is kind of what I'm really getting at) is, is it
possible to write web pages, so to speak, using xml and xslt. I
noticed that such applications like Front Page 2003 (I sometimes use
it as my html editor) let you make xml documents.


It's possible, but support for in-browser XML and XSLT is patchy.
Server-side transformation is strongly recommended.
From what I can see, I can easily make an .xml, .dtd, and .xslt
files in a folder somewhere in the document root on my web server,
but what I TRULY don't understand is how do I actually "call" the
xslt (since it does the actual transformation) from the web browser?


See the FAQ: http://xml.silmaril.ie/authors/style/
Does it need to be
"called" from an html document, or what? This is what I'm most
confused on, and thanks for any help clearing up the waters.


The stylesheet has to be referenced in the XML document. The browser
fetches it and applies it to perform the transformation.
(Also, any good real world examples for an xml+dtd+xslt would be
helpful too.)


See the links in the FAQ (it's all done that way).
http://xml.silmaril.ie/admin/availability/


Thank you, this is more what I was after, the server side aspect (though
the other way, referencing xml files directly, how this was done - which
I feel really stupid for asking now given the answer was staring me
smack in the face - was also what I was interested in.)

Many thanks to all.

--
Stan
May 31 '06 #5
Stan R. wrote:
how do I actually "call" the xslt (since it
does the actual transformation) from the web browser?


In general, you don't. Have the web server do it. Although you can
attach the stylsheet to the XML document and have the web browser do
it, that's still awfully dependent on particular browsers having XSLT
support.

How you do transforms on the server depends on the platform. You need
an XSLT transform engine like MSXML or Xalan and most server-side
languages will have a tutorial around somewhere.

To do it on the client, then you can use this (simplest)
http://www.w3.org/TR/xml-stylesheet/
but it gives an "all or nothing" result, either working or not working
and leaving a blank screen in the meantime. A few years ago M$oft were
pushing "data islands" as an alternative, where a HTML wrapper page had
XML and XSLT embedded within. This was quite a good technique, but too
vendor-specific. Nowadays you should probably do some searching around
for "AJAX" techniques (AJAX is bigger in scope than just XSLT, but they
do use XSLT a lot).

May 31 '06 #6
Stan R. wrote:
Peter Flynn wrote:
Stan R. wrote:
Hi. I'm an old programmer whose been finally reading up on xml the
past week. The concepts of xml, dtd, and xsl seem pretty straight
forward to me. I understand that xsl (as xslt for transformations )
can be used to transform xml data from an xml document into another
document, as specified in the templates.

One of the best examples I've seen by far is transforming a given
xml doc into html.

But where I seem to be getting stuck in the mud is how to really
apply xml documents. I know they can be used as data holders and
config files for regular applications. But how do you use it more
directly, to, say, generate a webpage from an xml doc.


You can write an XSLT transformation to do this, as you already
mention in the previous paragraph.
Also (and this is kind of what I'm really getting at) is, is it
possible to write web pages, so to speak, using xml and xslt. I
noticed that such applications like Front Page 2003 (I sometimes use
it as my html editor) let you make xml documents.


It's possible, but support for in-browser XML and XSLT is patchy.
Server-side transformation is strongly recommended.
From what I can see, I can easily make an .xml, .dtd, and .xslt
files in a folder somewhere in the document root on my web server,
but what I TRULY don't understand is how do I actually "call" the
xslt (since it does the actual transformation) from the web browser?


See the FAQ: http://xml.silmaril.ie/authors/style/
Does it need to be
"called" from an html document, or what? This is what I'm most
confused on, and thanks for any help clearing up the waters.


The stylesheet has to be referenced in the XML document. The browser
fetches it and applies it to perform the transformation.
(Also, any good real world examples for an xml+dtd+xslt would be
helpful too.)


See the links in the FAQ (it's all done that way).
http://xml.silmaril.ie/admin/availability/


Thank you, this is more what I was after, the server side aspect
(though the other way, referencing xml files directly, how this was
done - which I feel really stupid for asking now given the answer was
staring me smack in the face - was also what I was interested in.)

Many thanks to all.


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, a
la:

<?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.)

This would seem to make more sense to me, as you would have one file
containing your xml data, and thne have seperate xml files, each
including the main.xml, but different XSLT files.

Say, you have one template for html output, and another for plain text,
and another for some other format.

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.

Thanks for any insight.

--
Stan
May 31 '06 #7
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, a
la:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
If you want to try and have it rendered in the browser, yes.
Or if you simply want to record for others the location of a stylesheet.
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.)
In theory, yes, but not practically.
This would seem to make more sense to me, as you would have one file
containing your xml data, and thne have seperate xml files, each
including the main.xml, but different XSLT files.
But then you'd have three separate copies of your document to maintain.
That way madness lies.

Why not just put three xml-stylesheet Processing Instructions into one
copy of main.xml? Browsers don't honour that, at the moment, AFAIK,
despite having been asked to support variant stylesheets for the best
part of a decade.
Say, you have one template for html output, and another for plain text,
and another for some other format.

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.


No-one has ever asked to do it. The alternative is to have your three
stylesheets, but run them on a dummy 1-line XML file, and use the
document('main. xml') function to reference your main document, so that
it gets included for processing. In XLST2, you don't even need the
dummy file.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Jun 1 '06 #8
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, a
la:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
Not "include into", but "reference from".
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.)
That's exactly what the above achieves; the transformations are stored
in test.xslt, references from your main XML document.

If you mean "can I run different stylesheets at different times against
the same XML" -- Yes, but then you have to use a system that lets you
specify that pairing, rather than letting the XML file state which
stylesheet it expects you'd want to run against it. That's easy to do
when you're explicitly invoking an XSLT processor, less easy (because
less standardized) when you're trying to use a browser.
From everything I've found online thus far, it seem including xml files
in other xml files isn't a very clear topic


XInclude is clear, but not widely supported yet.... and not always the
right answer.
Jun 3 '06 #9
Peter Flynn 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, a la:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
If you want to try and have it rendered in the browser, yes.
Or if you simply want to record for others the location of a
stylesheet.


But if you want to use multiple style sheets for one xml, it maybe
better to perhaps leave a simple comment <!-- for HTML, use
test_html.xsl --> ... And just use an xslt processor (xsltproc.) I
assume this would be a good way?
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.)


In theory, yes, but not practically.
This would seem to make more sense to me, as you would have one file
containing your xml data, and thne have seperate xml files, each
including the main.xml, but different XSLT files.


But then you'd have three separate copies of your document to
maintain. That way madness lies.


No no no, one main xml with the actual data/layout, and one dtd or xsd,
and then seperate xsl files containing differnet templates for different
things, which I've discovered xsltproc does a good job of. For instance:

$ xmllint --noout --schema test.xsd test.xml
test.xml validates

$ xsltproc -o test.html test_html.xsl test.xml
$ xsltproc -o test.foo test_foo.xsl test.xml
$ xsltproc -o test.bar test_bar.xsl test.xml
....
Why not just put three xml-stylesheet Processing Instructions into one
copy of main.xml? Browsers don't honour that, at the moment, AFAIK,
despite having been asked to support variant stylesheets for the best
part of a decade.
Say, you have one template for html output, and another for plain
text, and another for some other format.

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.


No-one has ever asked to do it. The alternative is to have your three
stylesheets, but run them on a dummy 1-line XML file, and use the
document('main. xml') function to reference your main document, so that
it gets included for processing. In XLST2, you don't even need the
dummy file.


How do you use the document('main. xml') ?

--
Stan
Jun 8 '06 #10

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

Similar topics

9
3208
by: {AGUT2}=IWIK= | last post by:
Hello all, It's my fisrt post here and I am feeling a little stupid here, so go easy.. :) (Oh, and I've spent _hours_ searching...) I am desperately trying to read in an ASCII "stereolithography" file (*.STL) into my program. This has the following syntax... Begin STL Snippet **********
21
2532
by: Jason Heyes | last post by:
I want to allow objects of my class to be read from an input stream. I am having trouble with the implementation. Here are the different approaches I have tried: // Version 1.0 - Default constructors class MyClass { Foo foo; // foo and bar require default constructors Bar bar; public:
123
4003
by: C# Learner | last post by:
I've had enough of C#. I've had enough of using parentheses for every 'if' statement. I've had enough of having to mix assignment of return value of methods with flow control, making writing code that's both readable and consistent, impossible. C# is hindered by its predecessors and the Microsoft marketing department. If Anders had his way, this language would be a one where readable code isn't a near impossibility for non-trivial...
4
2065
by: DraguVaso | last post by:
Hi, I have files I need to read, which contains records with a variable lenght. What I need to do is Copy a Part of such a File to a new File, based on the a Begin- and End-record. I used this functions: Dim intMyFile As Integer = FreeFile() FileOpen(intMyFile, MakePathFile(strDirS, strFileS), OpenMode.Input, OpenAccess.Read, OpenShare.Shared, -1)
6
1750
by: DraguVaso | last post by:
Hi, I have files I need to read, which contains records with a variable lenght. What I need to do is Copy a Part of such a File to a new File, based on the a Begin- and End-record. I used this functions: Dim intMyFile As Integer = FreeFile() FileOpen(intMyFile, MakePathFile(strDirS, strFileS), OpenMode.Input, OpenAccess.Read, OpenShare.Shared, -1)
3
2756
by: nsh | last post by:
mailing.database.mysql, comp.lang.php subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING! version info: my isp is running my web page on a linux box with php ver. 4.4.1 according to phpinfo, the "mysql api client is ver. 4.0.25" - I have no idea how this relates, if at all, to the mysql engine's version. background:
2
1443
by: ChrisM | last post by:
I've got a medium sized project written in C# for .NET1.1 the project is live, but still under constant development. There seems to be a lot of new stuff in .NET2.0 that I'm missing out on, and now they're starting to talk about .NET3.0, I don't want to get left too far behind. What are the main issues (if any) porting a project from 1.1 to 2.0? Is it a case of just opening the project in 2.0, is there likely to be any problems in doing...
22
2584
by: gillisct | last post by:
I'd like to say I have a basic control of the C language. Is there any reccomended reading upon completion of K&R? Are there any projects someone new to C could study/watch over/ and eventually contribute to in order to get a grip on the development process and/or expand their knowledge? Thank you.
0
10410
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9984
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.