2 easy questions XML <==>XSLT

Discussion in 'XML' started by Peter David, Oct 31, 2003.

  1. Peter David

    Peter David Guest

    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
     
    Peter David, Oct 31, 2003
    #1
    1. Advertising

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


    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
     
    Dimitre Novatchev, Oct 31, 2003
    #2
    1. Advertising

  3. On Fri, 31 Oct 2003 20:26:32 +0000, Peter David wrote:

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


    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
     
    Alexander Schatten, Nov 1, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hazzard
    Replies:
    2
    Views:
    680
    Hazzard
    Apr 6, 2004
  2. Stylus Studio
    Replies:
    0
    Views:
    767
    Stylus Studio
    Aug 3, 2004
  3. Replies:
    4
    Views:
    715
  4. jkflens
    Replies:
    2
    Views:
    1,546
    jkflens
    May 30, 2006
  5. Bruno Desthuilliers
    Replies:
    5
    Views:
    415
    Bruno Desthuilliers
    Aug 29, 2007
Loading...

Share This Page