zoukankan
html css js c++ java
用javascript进行xsl转换
HTML代码
<
html
>
<
body
>
<
script
type
="text/javascript"
>
//
Load XML
var
xml
=
new
ActiveXObject(
"
Microsoft.XMLDOM
"
)
xml.async
=
false
xml.load(
"
cdcatalog.xml
"
)
//
Load the XSL
var
xsl
=
new
ActiveXObject(
"
Microsoft.XMLDOM
"
)
xsl.async
=
false
xsl.load(
"
cdcatalog.xsl
"
)
//
Transform
document.write(xml.transformNode(xsl))
</
script
>
</
body
>
</
html
>
XSL代码
att 1: cdcatalog.xsl
<?
xml version="1.0" encoding="ISO-8859-1"
?>
<!--
Edited with XML Spy v4.2
-->
<
xsl:stylesheet
version
="1.0"
xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
>
<
xsl:template
match
="/"
>
<
html
>
<
body
>
<
h2
>
My CD Collection
</
h2
>
<
table
border
="1"
>
<
tr
bgcolor
="#9acd32"
>
<
th
align
="left"
>
Title
</
th
>
<
th
align
="left"
>
Artist
</
th
>
</
tr
>
<
xsl:for-each
select
="catalog/cd"
>
<
tr
>
<
td
><
xsl:value-of
select
="title"
/></
td
>
<
td
><
xsl:value-of
select
="artist"
/></
td
>
</
tr
>
</
xsl:for-each
>
</
table
>
</
body
>
</
html
>
</
xsl:template
>
</
xsl:stylesheet
>
XML代码
cdcatalog.xml
<?
xml version="1.0" encoding="ISO-8859-1"
?>
<!--
Edited with XML Spy v4.2
-->
<
catalog
>
<
cd
>
<
title
>
Empire Burlesque
</
title
>
<
artist
>
Bob Dylan
</
artist
>
<
country
>
USA
</
country
>
<
company
>
Columbia
</
company
>
<
price
>
10.90
</
price
>
<
year
>
1985
</
year
>
</
cd
>
<
cd
>
<
title
>
Hide your heart
</
title
>
<
artist
>
Bonnie Tyler
</
artist
>
<
country
>
UK
</
country
>
<
company
>
CBS Records
</
company
>
<
price
>
9.90
</
price
>
<
year
>
1988
</
year
>
</
cd
>
<
cd
>
<
title
>
Greatest Hits
</
title
>
<
artist
>
Dolly Parton
</
artist
>
<
country
>
USA
</
country
>
<
company
>
RCA
</
company
>
<
price
>
9.90
</
price
>
<
year
>
1982
</
year
>
</
cd
>
<
cd
>
<
title
>
Still got the blues
</
title
>
<
artist
>
Gary Moore
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Virgin records
</
company
>
<
price
>
10.20
</
price
>
<
year
>
1990
</
year
>
</
cd
>
<
cd
>
<
title
>
Eros
</
title
>
<
artist
>
Eros Ramazzotti
</
artist
>
<
country
>
EU
</
country
>
<
company
>
BMG
</
company
>
<
price
>
9.90
</
price
>
<
year
>
1997
</
year
>
</
cd
>
<
cd
>
<
title
>
One night only
</
title
>
<
artist
>
Bee Gees
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Polydor
</
company
>
<
price
>
10.90
</
price
>
<
year
>
1998
</
year
>
</
cd
>
<
cd
>
<
title
>
Sylvias Mother
</
title
>
<
artist
>
Dr.Hook
</
artist
>
<
country
>
UK
</
country
>
<
company
>
CBS
</
company
>
<
price
>
8.10
</
price
>
<
year
>
1973
</
year
>
</
cd
>
<
cd
>
<
title
>
Maggie May
</
title
>
<
artist
>
Rod Stewart
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Pickwick
</
company
>
<
price
>
8.50
</
price
>
<
year
>
1990
</
year
>
</
cd
>
<
cd
>
<
title
>
Romanza
</
title
>
<
artist
>
Andrea Bocelli
</
artist
>
<
country
>
EU
</
country
>
<
company
>
Polydor
</
company
>
<
price
>
10.80
</
price
>
<
year
>
1996
</
year
>
</
cd
>
<
cd
>
<
title
>
When a man loves a woman
</
title
>
<
artist
>
Percy Sledge
</
artist
>
<
country
>
USA
</
country
>
<
company
>
Atlantic
</
company
>
<
price
>
8.70
</
price
>
<
year
>
1987
</
year
>
</
cd
>
<
cd
>
<
title
>
Black angel
</
title
>
<
artist
>
Savage Rose
</
artist
>
<
country
>
EU
</
country
>
<
company
>
Mega
</
company
>
<
price
>
10.90
</
price
>
<
year
>
1995
</
year
>
</
cd
>
<
cd
>
<
title
>
1999 Grammy Nominees
</
title
>
<
artist
>
Many
</
artist
>
<
country
>
USA
</
country
>
<
company
>
Grammy
</
company
>
<
price
>
10.20
</
price
>
<
year
>
1999
</
year
>
</
cd
>
<
cd
>
<
title
>
For the good times
</
title
>
<
artist
>
Kenny Rogers
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Mucik Master
</
company
>
<
price
>
8.70
</
price
>
<
year
>
1995
</
year
>
</
cd
>
<
cd
>
<
title
>
Big Willie style
</
title
>
<
artist
>
Will Smith
</
artist
>
<
country
>
USA
</
country
>
<
company
>
Columbia
</
company
>
<
price
>
9.90
</
price
>
<
year
>
1997
</
year
>
</
cd
>
<
cd
>
<
title
>
Tupelo Honey
</
title
>
<
artist
>
Van Morrison
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Polydor
</
company
>
<
price
>
8.20
</
price
>
<
year
>
1971
</
year
>
</
cd
>
<
cd
>
<
title
>
Soulsville
</
title
>
<
artist
>
Jorn Hoel
</
artist
>
<
country
>
Norway
</
country
>
<
company
>
WEA
</
company
>
<
price
>
7.90
</
price
>
<
year
>
1996
</
year
>
</
cd
>
<
cd
>
<
title
>
The very best of
</
title
>
<
artist
>
Cat Stevens
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Island
</
company
>
<
price
>
8.90
</
price
>
<
year
>
1990
</
year
>
</
cd
>
<
cd
>
<
title
>
Stop
</
title
>
<
artist
>
Sam Brown
</
artist
>
<
country
>
UK
</
country
>
<
company
>
A and M
</
company
>
<
price
>
8.90
</
price
>
<
year
>
1988
</
year
>
</
cd
>
<
cd
>
<
title
>
Bridge of Spies
</
title
>
<
artist
>
T`Pau
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Siren
</
company
>
<
price
>
7.90
</
price
>
<
year
>
1987
</
year
>
</
cd
>
<
cd
>
<
title
>
Private Dancer
</
title
>
<
artist
>
Tina Turner
</
artist
>
<
country
>
UK
</
country
>
<
company
>
Capitol
</
company
>
<
price
>
8.90
</
price
>
<
year
>
1983
</
year
>
</
cd
>
<
cd
>
<
title
>
Midt om natten
</
title
>
<
artist
>
Kim Larsen
</
artist
>
<
country
>
EU
</
country
>
<
company
>
Medley
</
company
>
<
price
>
7.80
</
price
>
<
year
>
1983
</
year
>
</
cd
>
<
cd
>
<
title
>
Pavarotti Gala Concert
</
title
>
<
artist
>
Luciano Pavarotti
</
artist
>
<
country
>
UK
</
country
>
<
company
>
DECCA
</
company
>
<
price
>
9.90
</
price
>
<
year
>
1991
</
year
>
</
cd
>
<
cd
>
<
title
>
The dock of the bay
</
title
>
<
artist
>
Otis Redding
</
artist
>
<
country
>
USA
</
country
>
<
company
>
Atlantic
</
company
>
<
price
>
7.90
</
price
>
<
year
>
1987
</
year
>
</
cd
>
<
cd
>
<
title
>
Picture book
</
title
>
<
artist
>
Simply Red
</
artist
>
<
country
>
EU
</
country
>
<
company
>
Elektra
</
company
>
<
price
>
7.20
</
price
>
<
year
>
1985
</
year
>
</
cd
>
<
cd
>
<
title
>
Red
</
title
>
<
artist
>
The Communards
</
artist
>
<
country
>
UK
</
country
>
<
company
>
London
</
company
>
<
price
>
7.80
</
price
>
<
year
>
1987
</
year
>
</
cd
>
<
cd
>
<
title
>
Unchain my heart
</
title
>
<
artist
>
Joe Cocker
</
artist
>
<
country
>
USA
</
country
>
<
company
>
EMI
</
company
>
<
price
>
8.20
</
price
>
<
year
>
1987
</
year
>
</
cd
>
</
catalog
>
查看全文
相关阅读:
【图论】Tarjan 缩点
【高级数据结构】左偏树
【网络流·最大流】ISAP(Improved Shortest Augumenting Path)详解
linux 压缩和解压文件(.gz.bz2)
Python requests库
jmeter 压测之动态数据关联
Jmeter 之数据库测试
Jmeter 参数未编码异常:java.net.URISyntaxException: Illegal character in query at index 172
Fiddler 过滤地址设置
loadrunner 连接mysql数据库获取数据进行参数化
原文地址:https://www.cnblogs.com/Lewis/p/639726.html
最新文章
BZOJ 1528: [POI2005]sam-Toy Cars、BZOJ 1826: [JSOI2010]缓存交换
BZOJ 3531 : [Sdoi2014]旅行
BZOJ 2243: [SDOI2011]染色
BZOJ 1036: [ZJOI2008]树的统计Count
BZOJ 1577: [Usaco2009 Feb]庙会捷运Fair Shuttle
BZOJ 1578: [Usaco2009 Feb]Stock Market 股票市场
BZOJ 1579: [Usaco2009 Feb]Revamping Trails 道路升级
BZOJ 1571: [Usaco2009 Open]滑雪课Ski
BZOJ 1584: [Usaco2009 Mar]Cleaning Up 打扫卫生
BZOJ 1010: [HNOI2008]玩具装箱toy
热门文章
[BZOJ2946] [Poi2000]公共串解题报告|后缀数组
[BZOJ3098]Hash Killer II解题报告
[BZOJ3926] [ZJOI2015]诸神眷顾的幻想乡|后缀自动机
[codevs3160]最长公共子串解题报告|后缀自动机
Codeforces 542C
Codeforces Round #301 解题报告
[BZOJ1982][POJ1740][Spoj 2021]Moving Pebbles|解题报告
[POJ2068]Nim解题报告
[BZOJ3698]XWW的难题解题报告|上下界网络流|有源汇最大流
[ZOJ2341]Reactor Cooling解题报告|带上下界的网络流|无源汇的可行流
Copyright © 2011-2022 走看看