SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Vitoria (Spain)
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can I generate an external .css from xml (with xsl)???

    How can I generate a .css file (out of html file) which uses data from .xml (for example img roots to apply a "background-image" to elements with an "id" or "class", also applied from an xml "IDREF" tag...)?

    I guess there is a way to create the .css file with an xsl but I don't know how.

  2. #2
    SitePoint Addict markchivs's Avatar
    Join Date
    Oct 2004
    Location
    Malvern Hills, UK
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have the source files either html or xml that you want to make this .css from? Can you post them?



  3. #3
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Vitoria (Spain)
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)



    XML FILE:

    <HOME>
    <IMAGE1>
    <RUTE>mydirectory/images/icons/mydog.gif </RUTE>
    <FORMAT>gif</FORMAT>
    <TYPE>5</TYPE>
    <DESCRIPTION>This is a picture about my dog</DESCRIPTION>
    <NOTES></NOTES>
    </IMAGE1>
    <MENU1>
    <MENU>
    <PARENT_KEY>1</PARENT_KEY>
    <PARENT>
    <MENU_KEY>1</MENU_KEY>
    <MENU_DESC>Home Main</MENU_DESC>
    <IDREF>MAIN01</IDREF>
    </PARENT>
    <MENU_KEY>2</MENU_KEY>
    ...
    ETC.
    ...
    ETC.
    ...
    ETC.
    ...
    </MENU1>

    ...
    ETC.
    ...
    ETC.
    ...
    ETC.
    ...


    </HOME>



    XSL FILE:

    <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">
    <head>

    <title>My Page</title>
    </head>
    <body>

    <p id="{//MENU1/MENU/PARENT/IDREF}">I want this paragraph to show, as a background-image, the value of //IMAGE1/RUTE node. But I don't want any style attribute in the html (neither a style tag into the head), but I want to create, from this xsl, a css external file that make use of this value, I mean //IMAGE1/RUTE</p>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>



    CSS FILE:

    p#MAIN01 { background: url('mydirectory/images/icons/mydog.gif');}

    I mean:

    p#//MENU1/MENU/PARENT/IDREF { background: url('//IMAGE1/RUTE');}




    What I'm looking for is a way (without java code or something...) to generate with this xsl (only from one xsl) the html source and the css file at time.


    Is this possible????


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •