using css in html embedded in xml rendered using xsl with javascript (phew)

Discussion in 'XML' started by confused, May 25, 2007.

  1. confused

    confused Guest

    Bear with me on this its a bit long.

    I have some xml with a section like

    <name>a great product</name>

    I use javascript to parse this with an xsl template and place the
    output in a <DIV> in the containing html page.
    All fine so far.

    Now I want to highlight some special offers so I change the XML to be

    <name><p style="background-color:yellow;color:red;">a great product</

    which works as long as I use the <xsl:copy-of select="name"> in the

    but I don't really want to plaster this around the xml so I simplified
    it to

    <name><p class="specialOffer">a great product</p></name>

    a created a css entry in an external style sheet of

    color: red;
    background-color: yellow;

    Again works, but I'm still not happy with this what I want is to
    change it to

    <name><specialOffer>a great product</specialOffer></name>

    and use the css entry
    color: red;
    background-color: yellow;

    but this doesn't seem to work, Why not? any ideas

    Many Thanks in advance espcially if you managed to read this far

    confused, May 25, 2007
    1. Advertisements

  2. confused

    confused Guest

    Oh and this works but only in mozilla not IE6

    <name><specialOffer class="specialOfferStyle">a great product</
    confused, May 25, 2007
    1. Advertisements

  3. confused

    [Jongware] Guest

    [snipped for convenience]
    Yeah -- you can't create arbitrary classes on the fly (-- in IE; as you noticed
    later, apparently you _can_ in Firefox. I dint know that one). Change the css
    declaration to ".specialOffer" (note the period), and use it either as <p
    class="specialOffer"> (for entire paragraphs) or as <span class="specialOffer">
    (as a text attribute).
    Verbosity is not a problem since you can add these attributes using the XSL.

    [Jongware], May 26, 2007
  4. since you are using xsl anyway why not just generate the standard html
    +css that you said worked earlier rather than a mixture if html and
    your own xml markup?

    adding a template like

    <xsl:template match="specialOffer">
    <div class="specialOffer">

    should be all you need, together with the css that styles div.specialOffer
    David Carlisle, May 26, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.