xsl-list
[Top] [All Lists]

Re: Detecting the tags inside CDATA section

2003-07-13 01:17:48
There are no "tags" inside a CDATA section -- it is a regular text node and
its value is a string. If a string happens to contains the text
representation of an xml document, this does not help -- it would be
necessary to call an extension function that will parse this string and
return the node-set comprising of its top element.

All the data inside the CDATA section here is actually an XML document

Then do put it as-is within the xml document -- not within a CDATA section.
In this case you'd be able to extract it with a single xsl:copy-of
instruction.



=====
Cheers,

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



In case
"Deepti Kodeboyina" <dkodeboy(_at_)cs(_dot_)indiana(_dot_)edu> wrote in message
news:Pine(_dot_)GSO(_dot_)4(_dot_)53(_dot_)0307130139470(_dot_)19137(_at_)cocktail(_dot_)cs(_dot_)indiana(_dot_)edu(_dot_)(_dot_)(_dot_)


I have a problem regarding a CDATA section in an XML file. I want to
convert this XML file into HTML to be displayed on a portal.My document
looks something like this

----------------------------
XML FILE
-----------------------------

<?xml version="1.0" encoding="UTF-8"?>
<gridDataServiceResponse xmlns="">
    <response name="requestsynch">
        <result name="Engine">GDS Engine - request
            &quot;requestsynch&quot; was stored successfully</result>
    </response>
    <response name="executerequestsynch">
        <result name="statement">COMPLETE</result>
        <result name="d1">
            <data><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RowSet PUBLIC '-//Sun Microsystems, Inc.//DTD RowSet//EN'
'http://java.sun.com/j2ee/dtds/RowSet.dtd'>
<RowSet>
<data>
  <row>
   <col>bitternut01.cs.indiana.edu</col>
   <col>1024</col>
   <col>896</col>
   <col>1024</col>
   <col>407626</col>
  </row>
  <row>
   <col>bitternut02.cs.indiana.edu</col>
   <col>1024</col>
   <col>768</col>
   <col>2048</col>
   <col>407522</col>
  </row>
</data>
</RowSet>]]></data>
        </result>
    </response>
</gridDataServiceResponse>

All the data inside the CDATA section here is actually an XML document
that I want to parse and convert to a html file. But I dont know how to
detect the tags inside a CDATA section and parse them. Does anyone know
how this could be done ?

Although it doesnt work my xslt stylesheet looks something like this
________________________________________
STYLESHEET
________________________________________

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:util="http://www.oracle.com/XSL/Transform/java/Util";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xalan="http://xml.apache.org/xslt";>

<xsl:template match="/">
  <html>
  <body>
    <h2>Query Output</h2>
    <table border="1">
                <xsl:for-each select="gridDataServiceResponse/response">
                        <tr bgcolor="#99CCFF">
                                <td>Response-<xsl:value-of
select="@name"/></td>
                        </tr>

                        <xsl:for-each select="result">
                                <tr>
                                        <td>Result<xsl:value-of
select="@name"/></td>
                                </tr>
                                <tr>
                                        <td><xsl:value-of
select="."/></td>
                                </tr>


                                <xsl:for-each select="data">
                                        <xsl:for-each
select="/RowSet/data/row">
                                        <tr bgcolor="#FFFFFF">
                                                <xsl:for-each
select="col">
                                                <td><xsl:value-of
select="."/></td>
                                                </xsl:for-each>
                                        </tr>
                                        </xsl:for-each>
                                </xsl:for-each>

                        </xsl:for-each>

                </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

I am trying to convert the XML file into a table in HTML. I basically need
to know how to detect the tags inside a CDATA section.

Thank you,
Deepti Kodeboyina
Computer Science Dept.
(dkodeboy(_at_)cs(_dot_)indiana(_dot_)edu)

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>