Returns the HTML code with the result of the query.

1 sql.toHTML

Generate a table HTML with the values obtained from:

  • select (or union) in XSQL
  • select in SQL nativo indicated between the tags nativesql
  • vtable
  • a xml of a sqlresponse

The columns which has defined an attribute with include will be converted to the value defined in the include.

<sql.toHTML
    table-style='table-style'
    table-titles='table-titles'
    th-style='th-style'
    th-colour='th-colour'
    th-bgcolor='th-bgcolor'
    convert='convert'
>
    <in> ?
        <vtable /> *
        <soapsqlresponse /> *
    </in>
    <union /> ?
    <select /> ?
    <nativesql /> ?
</sql.toHTML>

Exceptions

sql exception ...

Error of sql.

Example

Create a table in html, from a native code.

Copy
<xsql-script name='sql_sql2html1'>
    <body>
        <println>
            <sql.toHTML table-style='bgcolour: \#CCCCCC' th-bgcolour='azure'>
                <nativesql>SELECT cdiary FROM cdiary</nativesql>
            </sql.toHTML>
        </println>
    </body>
</xsql-script>

When the colour of the table is introduced, you should note that the bgcolour value has to be preceded by '\'(scape character), so that the same RGB value will not be interpreted as a variable.

Example

Create a table in html, from a tag code.

Copy
<xsql-script name='sql_sql2html2'>
   <body>
       <println>
           <sql.toHTML table-style='bgcolour: \#CCCCCC' th-bgcolour='azure'>
                <select>
                   <columns>cdiary</columns>
                   <from table='cdiary' />
               </select>
           </sql.toHTML>
       </println>
   </body>
</xsql-script>

When the table colour is introduced, you should note that the bgcolour value has to be preceded by '\'(scape character), so that the same RBG value will not be interpreted as variable.

Example

Creation of a XML structure through a vtable.

Copy
<xsql-script name='sql_sql2html3'>
    <body>
        <vtable name='v1'>
            <column name='code' type='char' unique='true' />
            <column name='name' type='char' size='25' />
            <column name='number' type='integer' />
            <column name='balance'  type='decimal' scale='2' editable='true' />
        </vtable>
        <vtable.insert name='v1'>
            <column name='code'>A</column>
            <column name='name'>Nombre AA</column>
            <column name='number'>0</column>
            <column name='balance'>12.9</column>
        </vtable.insert>
        <vtable.insert name='v1'>
            <column name='code'>B</column>
            <column name='name'>Name BB</column>
            <column name='number'>1</column>
            <column name='balance'>-17.99</column>
        </vtable.insert>
        <println>
            <sql.toHTML table-style='bgcolour: \#CCCCCC' th-bgcolour='azure' table-titles='cdiary'>
                <in>
                    <v1/>
                </in>
            </sql.toHTML>
        </println>
    </body>
</xsql-script>

Generate the following HTML table:

Copy
<TABLE BORDER='1' CELLPADDING='2' CELLSPACING='0' STYLE='bgcolor: #CCCCCC'>
    <TR>
        <TH VALING='TOP' style='margin:0; border: 1px solid gray; font-weight:bold; colour: #000000; background-colour: azure;'>Diary</TH>
        <TH VALING='TOP' style='margin:0; border: 1px solid gray; font-weight:bold; colour: #000000; background-colour: azure;'>name</TH>
        <TH VALING='TOP' style='margin:0; border: 1px solid gray; font-weight:bold; colour: #000000; background-colour: azure;'>number</TH>
        <TH VALING='TOP' style='margin:0; border: 1px solid gray; font-weight:bold; colour: #000000; background-colour: azure;'>balance</TH>
    </TR>
    <TR>
        <TD>A</TD>
        <TD>Name AA</TD>
        <TD ALIGN='RIGHT' NOWRAP>0</TD>
        <TD ALIGN='RIGHT' NOWRAP>12,9</TD>
    </TR>
    <TR>
        <TD>B</TD>
        <TD>Name BB</TD>
        <TD ALIGN='RIGHT' NOWRAP>1</TD>
        <TD ALIGN='RIGHT' NOWRAP>-17,99</TD>
    </TR>
</TABLE>
Example

Create a table in html with the data obtained of the result of a soap call.

Copy
<xsql-script name='sql_sql2html4'>
    <body>
        <set name='m_response'>
            <soap.call
                url='http://localhost:80/soap/servlet/rpcrouter'
                uri='urn:SOAPSQLServer'
                method='executeSQL'
                user='demo'
                password='abcdemo'
            >
                <parameters>
                    <parameter name='database'>demo_sports1</parameter>
                    <parameter name='sqlstmt'>SELECT * FROM cdiary</parameter>
                </parameters>
            </soap.call>
        </set>
        <println>
            <m_response />
        </println>
        <println>
            <sql.toHTML table-style='bgcolour: \#CCCCCC' th-bgcolour='azure' table-titles='cdiary'>
                <in><m_response/></in>
            </sql.toHTML>
        </println>
    </body>
</xsql-script>