XST converting XML to HTML question

Discussion in 'XML' started by Bill Sneddon, Jul 15, 2003.

  1. Bill Sneddon

    Bill Sneddon Guest

    I am using an XML file produced by doing a save-as in Excel. The file
    has content that looks like one of these three examples lines:

    <Cell ss:StyleID="s24"><ss:Data ss:Type="String"
    xmlns="http://www.w3.org/TR/REC-html40">H<Sub>3</Sub><Font>PO</Font><Sub>4
    </Sub></ss:Data></Cell>

    <Cell ss:StyleID="s24"><Data ss:Type="String">GC</Data></Cell>

    <Cell ss:StyleID="s24"><ss:Data ss:Type="String"
    xmlns="http://www.w3.org/TR/REC-html40">I<Sub>CC</Sub></ss:Data></Cell>


    What I would like to do is produce html that formats the subscript
    properly. For example I would like to display H3PO4 with the 3 & 4
    subscripted like this H<Sub>3</Sub><Font>PO</Font><Sub>4</Sub>

    when I do this select <xsl:value-of select="Cell[1]"/>
    I get H3PO4 back. I<Sub>CC</Sub> would also be valid data so
    I can't make assuptions about the number of <Sub> tags and where they
    might be in the data.

    I am not sure if the solution to this is easy or not. I still trying to
    understand XSL and may be overlooking something.



    Bill
     
    Bill Sneddon, Jul 15, 2003
    #1
    1. Advertising

  2. Bill Sneddon

    Bill Sneddon Guest

    I could not make this work at all.
    I finally had to convert <Sub> -> &lt;Sub&gt;
    Do the transform and convert it back.

    It still seems possible but I could not get it to work after many attempts.

    In your example below what causes the H and the 3 to be outputed?
    I am currently working in a for-each loop but had the same results
    when trying to apply templates.

    <Data>H<Sub>3</Sub><Font>PO</Font><Sub>4
    </Sub></ss:Data></Cell>


    Bill

    Peter Flynn wrote:
    > Bill Sneddon wrote:
    >
    >> I am using an XML file produced by doing a save-as in Excel. The file
    >> has content that looks like one of these three examples lines:
    >>
    >> <Cell ss:StyleID="s24"><ss:Data ss:Type="String"
    >> xmlns="http://www.w3.org/TR/REC-html40">H<Sub>3</Sub><Font>PO</Font><Sub>4
    >> </Sub></ss:Data></Cell>
    >>
    >> <Cell ss:StyleID="s24"><Data ss:Type="String">GC</Data></Cell>
    >>
    >> <Cell ss:StyleID="s24"><ss:Data ss:Type="String"
    >> xmlns="http://www.w3.org/TR/REC-html40">I<Sub>CC</Sub></ss:Data></Cell>
    >>
    >>
    >> What I would like to do is produce html that formats the subscript
    >> properly. For example I would like to display H3PO4 with the 3 & 4
    >> subscripted like this H<Sub>3</Sub><Font>PO</Font><Sub>4</Sub>
    >>
    >> when I do this select <xsl:value-of select="Cell[1]"/>
    >> I get H3PO4 back.

    >
    >
    > That's because value-of gives you the string content, stripped
    > of any internal markup. You need to write a template for Cell
    > and for Sub:
    >
    > <xsl:template match="Cell">
    > <xsl:apply-templates/>
    > </xsl:template>
    >
    > <xsl:template match="Sub">
    > <sub>
    > <xsl:apply-templates/>
    > </sub>
    > </xsl:apply-templates>
    >
    > ///Peter
    >
     
    Bill Sneddon, Jul 18, 2003
    #2
    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. Jeremy Pyle

    XST Process Failure

    Jeremy Pyle, Jul 14, 2003, in forum: VHDL
    Replies:
    0
    Views:
    1,173
    Jeremy Pyle
    Jul 14, 2003
  2. E. Backhus
    Replies:
    2
    Views:
    7,084
    Alain
    Jul 25, 2003
  3. niels
    Replies:
    3
    Views:
    365
    Alexander Schatten
    Oct 1, 2003
  4. jkflens
    Replies:
    2
    Views:
    1,500
    jkflens
    May 30, 2006
  5. Fredxx
    Replies:
    29
    Views:
    2,137
    rickman
    Jun 30, 2009
Loading...

Share This Page