You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Jørn Tage Tyskerud <jo...@iconmedialab.no> on 2001/03/19 13:51:58 UTC

RE: Advice on proper use of SQL in Xalan (Possible bug..?)

> The SQL Schema looks something like this
> 
> <row-set>
>     <!-- One occurrence for each Column in query -->
>    <column-header attribute="value"/>
> 
>     <!-- One occurrence for each row in query -->
>    <row>
> 
>        <!-- One occurrence for each Column in query -->
>         <col attribute="value">ColValue</col>
>     </row>
> </row-set>
> 
> 
> The Column Header and Col attributes consists of the following,
> the meaning of each can be found in the JDBC ResultSetMetaData
> class.
> 
> "column-display-size"
> "column-label";
> "column-name";
> "column-type";
>  "column-type-name";
> "precision";
>  "scale";
> "schema-name";
> "table-name";
> "case-sensitive";
> "definitely-writable";
> "nullable";
> "signed";
> "writable";
> "searchable";
> 
> The Example in the extensions area uses successive templates to
> process each column in each row, you can also do it with for-each
> loops. I am not sure which is more XSL efficient. Here is an example
> of a for each process. I have not actually tried this example 
> but it should
> be close.
> 
> One Caveat here, the current version has a bug, you have to 
> run through
> the column-headers to populate the meta data for each column before
> you can access the attributes at the col level. The can be 
> done without
> changing the output by using the empty for loop.
> 
>    <!-- Force Col Attributes to be populated -->
>   <xsl:for-each select="$table/row-set/column-header"/>
> 
>   <xsl:for-each select="$table/row-set/row">
> 
>       <xsl:for-each select="row">
>             <xsl:text>Processing Row </xsl:text>
>             <xsl:number />
> 
>             <xsl:for-each select="col">
>                 <xsl:text>Value for Column </xsl:text>
>                 <xsl:value-of select="@column-label" />
>                 <xsl:text> Its value is </xsl:text>
>                 <xsl:value-of select="normalize-space(text())" />
>           </xsl:for-each>
> 
>     </xsl:for-each>
>   </xsl:for-each>
> 
> 
> Hope this helps.
> John G
> 
> 

-- John,

thanks. This answered a lot of questions. You example works for char data;
however, I' not able to access the num data. The table looks like this:

create table kurser(
	kurs_id char(10),
	avanse num(15,2),
	kurs num(15,2),
	status char(1),
	distkode num(15,2)
)

So, by using text(), I'm able to access the kurs_id and the status; however,
how to I access the num data fields. I've tried things like:

	-> . 
	-> @avanse
	-> *|*@
	-> number(.)
	-> text()
	->etc...

They all fail or return nothing. I've printed the @column-type attr for the
table data:

Type of Column  1
Type of Column  3
Type of Column  3
Type of Column  1
Type of Column  3	

The org.w3c.dom.Node documentation says 1 is an ELEMENT-NODE and 3 is a
TEXT-NODE. Is the @column-type statement printing the org.w3c.dom.Node
values? If so, the table num data is returned as text nodes and each node
should be accessible through the text() function right? 

What am I missing here? Once again, thanks for any help og pointers to
possible source of information.

Regards,
Jørn Tage


	

Re: Advice on proper use of SQL in Xalan (Possible bug..?)

Posted by John Gentilin <jo...@eyecatching.com>.
I will look into it. If it is a problem, it will show up in a stylesheet
I plan to write today.

JG

Jørn Tage Tyskerud wrote:

> > The SQL Schema looks something like this
> >
> > <row-set>
> >     <!-- One occurrence for each Column in query -->
> >    <column-header attribute="value"/>
> >
> >     <!-- One occurrence for each row in query -->
> >    <row>
> >
> >        <!-- One occurrence for each Column in query -->
> >         <col attribute="value">ColValue</col>
> >     </row>
> > </row-set>
> >
> >
> > The Column Header and Col attributes consists of the following,
> > the meaning of each can be found in the JDBC ResultSetMetaData
> > class.
> >
> > "column-display-size"
> > "column-label";
> > "column-name";
> > "column-type";
> >  "column-type-name";
> > "precision";
> >  "scale";
> > "schema-name";
> > "table-name";
> > "case-sensitive";
> > "definitely-writable";
> > "nullable";
> > "signed";
> > "writable";
> > "searchable";
> >
> > The Example in the extensions area uses successive templates to
> > process each column in each row, you can also do it with for-each
> > loops. I am not sure which is more XSL efficient. Here is an example
> > of a for each process. I have not actually tried this example
> > but it should
> > be close.
> >
> > One Caveat here, the current version has a bug, you have to
> > run through
> > the column-headers to populate the meta data for each column before
> > you can access the attributes at the col level. The can be
> > done without
> > changing the output by using the empty for loop.
> >
> >    <!-- Force Col Attributes to be populated -->
> >   <xsl:for-each select="$table/row-set/column-header"/>
> >
> >   <xsl:for-each select="$table/row-set/row">
> >
> >       <xsl:for-each select="row">
> >             <xsl:text>Processing Row </xsl:text>
> >             <xsl:number />
> >
> >             <xsl:for-each select="col">
> >                 <xsl:text>Value for Column </xsl:text>
> >                 <xsl:value-of select="@column-label" />
> >                 <xsl:text> Its value is </xsl:text>
> >                 <xsl:value-of select="normalize-space(text())" />
> >           </xsl:for-each>
> >
> >     </xsl:for-each>
> >   </xsl:for-each>
> >
> >
> > Hope this helps.
> > John G
> >
> >
>
> -- John,
>
> thanks. This answered a lot of questions. You example works for char data;
> however, I' not able to access the num data. The table looks like this:
>
> create table kurser(
>         kurs_id char(10),
>         avanse num(15,2),
>         kurs num(15,2),
>         status char(1),
>         distkode num(15,2)
> )
>
> So, by using text(), I'm able to access the kurs_id and the status; however,
> how to I access the num data fields. I've tried things like:
>
>         -> .
>         -> @avanse
>         -> *|*@
>         -> number(.)
>         -> text()
>         ->etc...
>
> They all fail or return nothing. I've printed the @column-type attr for the
> table data:
>
> Type of Column  1
> Type of Column  3
> Type of Column  3
> Type of Column  1
> Type of Column  3
>
> The org.w3c.dom.Node documentation says 1 is an ELEMENT-NODE and 3 is a
> TEXT-NODE. Is the @column-type statement printing the org.w3c.dom.Node
> values? If so, the table num data is returned as text nodes and each node
> should be accessible through the text() function right?
>
> What am I missing here? Once again, thanks for any help og pointers to
> possible source of information.
>
> Regards,
> Jørn Tage
>
>