xslt的简单使用[xml-->html]

2008-02-23 05:51:24来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

XSLT命令[xml格式转换]
1.循环 <xsl:for-each...>
<xsl:for-each select="BookList/Item">
<tr>
<th align="left"> <xsl:value-of select=".//title" /></th>
<td><xsl:value-of select=".//categroy" /></td>
<td><xsl:value-of select=".//release-date" /></td>
<td><xsl:value-of select=".//author" /></td>
<td><xsl:value-of select="@price" /></td>
</tr>
</xsl:for-each>
2.排序 <xsl:sort...>
3.条件处理 <xsl:if...>或<xsl:choose...>或<xsl:when...>
4.名称模板
<xsl:template name...<xsl:template name...>,<xsl:param...>
<xsl:with-param...>,<xsl:call-template...>
5.编号方式 <xsl:number value format...>

xml文档[Article.xml] <?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type='text/xsl' href='Article.xsl'?>
<Articles>
<Article>
<ArticleID>2897</ArticleID>
<Title>[分享]千万数量级分页存储过程(带效果演示)</Title>
<Author>网络</Author>
<Abstract>[分享]千万数量级分页存储过程(带效果演示)</Abstract>
<PostDateTime>2006-02-27 18:29:53</PostDateTime>
<Dots>7</Dots>
<ColumnURL>/web/Article/viewColumn.aspx?ColID=19</ColumnURL>
<ColumnID>19</ColumnID>
<ColumnName>SQL Server</ColumnName>
<FileType>1</FileType>
<FilePath>resource/sql server/2006-02-27/20060227182953.htm</FilePath>
<Editor>网络</Editor>
<EditDateTime>2006-02-27 18:29:53</EditDateTime>
<Content>
[分享]千万数量级分页存储过程(带效果演示)效果演示:
http://www.cn5135.com/_App/Opportunities/QueryResult.aspx
CREATE PROCEDURE CN5135_SP_Pagination
/******************************************************************
千万数量级分页存储过程
*******************************************************************
参数说明:
1.Tables :表名称,视图
2.PrimaryKey :主关键字
3.Sort :排序语句,不带Order By 比如:NewsID Desc,OrderRows Asc
4.CurrentPage :当前页码
5.PageSize :分页尺寸
6.Filter :过滤语句,不带Where
7.Group :Group语句,不带Group By
效果演示:http://www.cn5135.com/_App/Opportunities/QueryResult.aspx
***************************************************************/
(
@Tables varchar(1000),
@PrimaryKey varchar(100),
@Sort varchar(200) = NULL,
@CurrentPage int = 1,
@PageSize int = 10,
@Fields varchar(1000) = '*',
@Filter varchar(1000) = NULL,
@Group varchar(1000) = NULL
)
AS
/*默认排序*/
IF @Sort IS NULL OR @Sort = ''
SET @Sort = @PrimaryKey
DECLARE @SortTable varchar(100)
DECLARE @SortName varchar(100)
DECLARE @strSortColumn varchar(200)
>DECLARE @operator char(2)
DECLARE @type varchar(100)
DECLARE @prec int
/*设定排序语句.*/
IF CHARINDEX('DESC',@Sort)&gt;0
BEGIN
SET @strSortColumn = REPLACE(@Sort, 'DESC', '')
SET @operator = '&lt;='
END
ELSE
BEGIN
IF CHARINDEX('ASC', @Sort) = 0
SET @strSortColumn = REPLACE(@Sort, 'ASC', '')
SET @operator = '&gt;='
END
IF CHARINDEX('.', @strSortColumn) &gt; 0
BEGIN
SET @SortTable = SUBSTRING(@strSortColumn, 0, CHARINDEX('.',@strSortColumn))
SET @SortName = SUBSTRING(@strSortColumn, CHARINDEX('.',@strSortColumn) 1, LEN(@strSortColumn))
END
ELSE
BEGIN
SET @SortTable = @Tables
SET @SortName = @strSortColumn
END
SELECT @type=t.name, @prec=c.prec
FROM sysobjects o
JOIN syscolumns c on o.id=c.id
JOIN systypes t on c.xusertype=t.xusertype
WHERE o.name = @SortTable AND c.name = @SortName
IF CHARINDEX('char', @type) &gt; 0
SET @type = @type '(' CAST(@prec AS varchar) ')'
DECLARE @strPageSize varchar(50)
DECLARE @strStartRow varchar(50)
DECLARE @strFilter varchar(1000)
DECLARE @strSimpleFilter varchar(1000)
DECLARE @strGroup varchar(1000)
/*默认当前页*/
IF @CurrentPage &lt; 1
SET @CurrentPage = 1
/*设置分页参数.*/
SET @strPageSize = CAST(@PageSize AS varchar(50))
SET @strStartRow = CAST(((@CurrentPage - 1)*@PageSize 1) AS varchar(50))
/*筛选以及分组语句.*/
IF @Filter IS NOT NULL AND @Filter != ''
BEGIN
SET @strFilter = ' WHERE ' @Filter ' '
SET @strSimpleFilter = ' AND ' @Filter ' '
END
ELSE
BEGIN
SET @strSimpleFilter = ''
SET @strFilter = ''
END
IF @Group IS NOT NULL AND @Group != ''
SET @strGroup = ' GROUP BY ' @Group ' '
ELSE
SET @strGroup = ''
/*执行查询语句*/
EXEC(
'
DECLARE @SortColumn ' @type '
SET ROWCOUNT ' @strStartRow '
SELECT @SortColumn=' @strSortColumn ' FROM ' @Tables @strFilter ' '
@strGroup ' ORDER BY ' @Sort '
SET ROWCOUNT ' @strPageSize '
SELECT ' @Fields ' FROM ' @Tables ' WHERE ' @strSortColumn @operator
' @SortColumn ' @strSimpleFilter ' ' @strGroup ' ORDER BY ' @Sort '
'

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:XSL中利用xsl:for-each时给每一项添加序号

下一篇:关于XSL中count()的使用