网络编程
位置:首页>> 网络编程>> XML编程>> XML文件的显示——CSS和XSL(4)

XML文件的显示——CSS和XSL(4)

 来源:ccidnet.com 发布时间:2007-10-15 18:48:00 

标签:xml,xsl,css

例2 2.xml源文件


〈?xml version="1.0" encoding="GB2312" ?〉

〈?xml-stylesheet href="first.xsl" type="text/xsl" ?〉

〈data〉

〈book〉

〈title〉XML入门精解〈/title〉

〈author〉张三〈/author〉

〈price unit="人民币"〉20.00〈/price〉

〈/book〉

〈book〉

〈title〉XML语法〈/title〉

〈!-- 即将出版 --〉

〈author〉李四〈/author〉

〈price unit="人民币"〉18.00〈/price〉

〈memo〉此书是著名计算机科学专家编著,

极具权威性。在书中又穿插许多精彩的例

子,所以可读性又极强。

〈/memo〉

〈/book〉

〈/data〉

First.xsl源文件

〈?xml version="1.0" encoding="GB2312" ?〉

〈xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"〉

〈xsl:template match="/"〉

〈html〉〈body〉

〈center〉〈h2〉书籍信息〈/h2〉〈/center〉

〈div align="center"〉〈center〉

〈table border="1" cellpadding="5" bgcolor="#4EB7DE"〉

〈tr〉

〈th〉书名〈/th〉〈th〉作者〈/th〉〈th〉价格(人民币)〈/th〉

〈th〉备注〈/th〉

〈/tr〉

〈xsl:for-each select="data/book" order-by="title"〉

〈tr〉

〈td〉〈xsl:value-of select="title"/〉〈/td〉

〈td〉〈xsl:value-of select="author"/〉〈/td〉

〈td〉〈xsl:value-of select="price"/〉〈/td〉

〈td width="150"〉〈xsl:value-of select="memo"/〉〈/td〉

〈/tr〉

〈/xsl:for-each〉

〈/table〉

〈/center〉〈/div〉

〈/body〉〈/html〉

〈/xsl:template〉

〈/xsl:stylesheet〉



表1 常用的文字相关属性

属性名称

功能描述

设置值

color

文字的颜色

颜色的英文名或十六进制的rgb色

color:red color:#f00f01

font-family

文字字型

字型名称

font-family:宋体

font-size

文字大小

pt、in、cm、px、xx-small、x-small、small、medium、large、x-large、xx-large

font-size:x-large font-size:1cm

font-weight

文字粗细

extra-light、light、demi-light、medium、demi-bold、bold、extra-bold

font-weight:light

font-style

字型样式

normal、italic

font-style:italic

text-align

文字位置

center、right、left

text-align:left

text-indent

文字缩排

pt(点)in(英寸)cm(厘米)px(像素)

text-indent:20pt

text-transform

大小写转换

capitalize、uppercase、lowercase

text-transform:uppercase

text-decoration

文字加线设置

underline、ouerline、line-through

text-decora:underline




表2 常用的版面排列属性

属性名称

功能描述

设置值与单位

display

组件的显示状态

none、block、inline

width

组件的宽度

pt、in、cm、px

background-color

组件的背景颜色

颜色英文名或十六进制rgb

padding

组件与四边的距离

pt、in、cm、px

padding-left

组件与左边的距离

pt、in、cm、px

padding-right

组件与右边的距离

pt、in、cm、px

padding-top

组件与上边的距离

pt、in、cm、px

padding-bottom

组件与下边的距离

pt、in、cm、px

border

方形边框


border-left

方形的左边框


border-right

方形的左边框


border-top

方形的上边框


border-bottom

方形的下边框


border-color

方形边框的颜色

颜色的英文名或十六进制rgb

border-wide

方形边框的宽度

thin 、medium、thick、pt、in、cm、px

border-style

方形边框的样式

none、dotted、solid、double



0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com