2 easy questions XML <==>XSLT

P

Peter David

Hi all,

1) I have created a huge XML "data base" consisting of people with
<name>Charlie</name> <address>High street></address> etc.

I wanna use this xml-data base for various HTM-pages for me to surf to; one
could be to list all red-haireds on one htm-page, or all people with income
10,000. In other words many HTM-pages based upon the same data base, i.e.
ONE file "people.xml".

I can create various xslt-files to achieve these "output"-htm-screens.

But only ONE can be seen, since I have to code the name of the xslt-file
inside the xml-code
<?xml-stylesheet type ="text/xsl" href="redhaireds.xsl"?>

How do I solve this??

2) Within the tags in my XML-file
<description> bla bla bla</description> I want to have HTML-functions
visible within the text, e.g- one specific word will be bold (How do I write
<B> within the text ??) or a line break (How do I write <BR> ?)

Thanks!
Peter
 
D

Dimitre Novatchev

Hi all,
1) I have created a huge XML "data base" consisting of people with
<name>Charlie</name> <address>High street></address> etc.

I wanna use this xml-data base for various HTM-pages for me to surf to; one
could be to list all red-haireds on one htm-page, or all people with income i.e.
ONE file "people.xml".

I can create various xslt-files to achieve these "output"-htm-screens.

But only ONE can be seen, since I have to code the name of the xslt-file
inside the xml-code
<?xml-stylesheet type ="text/xsl" href="redhaireds.xsl"?>

How do I solve this??

Don't use the "xml-stylesheet" processing instruction.
Instead, use script as part of the html page. This script will create the
two DOM objects and load them with the source xml document and with the
stylesheet. Then it will execute a method, which actually performs the
transformation.

How this is done is vendor - specific and you must read the documentation
provided by the vendor of the specific XSLT processor you're using. For
example in the case of MSXML4 this is described in the MSXML4 SDK
documentation.

2) Within the tags in my XML-file
<description> bla bla bla</description> I want to have HTML-functions
visible within the text, e.g- one specific word will be bold (How do I write
<B> within the text ??) or a line break (How do I write <BR> ?)

<someText>Normal and <b>bold</b>text and <br /> a second line of
text</someText>



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 
A

Alexander Schatten

Hi all,

1) I have created a huge XML "data base" consisting of people with
<name>Charlie</name> <address>High street></address> etc.

I wanna use this xml-data base for various HTM-pages for me to surf to;
one could be to list all red-haireds on one htm-page, or all people with
income
ONE file "people.xml".

I can create various xslt-files to achieve these "output"-htm-screens.

But only ONE can be seen, since I have to code the name of the xslt-file
inside the xml-code
<?xml-stylesheet type ="text/xsl" href="redhaireds.xsl"?>

How do I solve this??

use an XML framework like Apache Cocoon or create the html documents using
an xslt processor like Xalan: there you can define the stylesheet to be
used. but far better then using xalan directly is using the style target
in apache ant.
2) Within the tags in my XML-file
<description> bla bla bla</description> I want to have HTML-functions
visible within the text, e.g- one specific word will be bold (How do I
write <B> within the text ??) or a line break (How do I write <BR> ?)

(1) dont mix visual with generic markup

(2) if you *really* cannot avoid it, there is no problem in writing:

<description>bla bla <b>bla</bla><br/> blabla </description>

you just have to write a fitting XSLT stylesheet.

btw. the code above is also called "mixed content": you find it in any XML
book/tutorial.


alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top