xslt的简略应用[xml--html]

作者:北京诚信汇发物流有限公司  来源:www.cxhfwL.com  发布时间:2017-09-12 16:31:59
xslt鐨勭畝鐣ュ簲鐢╗xml--html]

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>
[鍒嗕韩]鍗冧竾鏁伴噺绾у垎椤靛瓨鍌ㄨ繃绋嬶紙甯︽晥鏋滄紨绀猴級鏁堟灉婕旂ず锛�br />
CREATE PROCEDURE CN5135_SP_Pagination
/******************************************************************
鍗冧竾鏁伴噺绾у垎椤靛瓨鍌ㄨ繃绋�br /> *******************************************************************
鍙傛暟璇存槑:
1.Tables :琛ㄥ悕绉�,瑙嗗浘
2.PrimaryKey :涓诲叧閿瓧
3.Sort :鎺掑簭璇彞锛屼笉甯rder By 姣斿锛歂ewsID Desc,OrderRows Asc
4.CurrentPage :褰撳墠椤电爜
5.PageSize :鍒嗛〉灏哄
6.Filter :杩囨护璇彞锛屼笉甯here
7.Group :Group璇彞,涓嶅甫Group By
鏁堟灉婕旂ず锛�br /> ***************************************************************/
(
@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 + '
'
)
GO
<!--<![CDATA[]]>-->
</Content>
<Remarks>
<Remark PostUserName="guest" PostDateTime="2006-04-10 15:26:22">
<PostUserNickName>
璁垮
</PostUserNickName>
<Content>
OK!
</Content>
</Remark>
<Remark PostUserName="test" PostDateTime="2006-04-10 09:18:35">
<PostUserNickName>
娓稿
</PostUserNickName>
<Content>
good
</Content>
</Remark>
<Remark PostUserName="dream" PostDateTime="2006-04-10 08:45:35">
<PostUserNickName>
dream
</PostUserNickName>
<Content>
涓嶉敊!
</Content>
</Remark>
<Remark PostUserName="no3" PostDateTime="2006-04-8 15:10:45">
<PostUserNickName>
姊﹀够3鍙�br /> </PostUserNickName>
<Content>
鐪嬬湅
</Content>
</Remark>
<Remark PostUserName="admin" PostDateTime="2006-04-08 12:12:35">
<PostUserNickName>

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:武汉网站建设 https://www.feimao666.com


上一篇:车手不能忽略的直通车定向投放策略
下一篇:最后一页