|
查看: 943|回复: 2
|
XSL Document()
[复制链接]
|
|
|
小弟有三个 xml
每个都拥有一样的结构
EXAMPLE:- <?xml version="1.0"?>
- <train>
- <customer>A</customer>
- <bus no="BC1243">
- <date>12-12-2009</date>
- <seat>24A</seat>
- </bus>
- </train>
- <train>
- <customer>B</customer>
- <bus no="BC1243">
- <date>12-12-2009</date>
- <seat>24B</seat>
- </bus>
- </train>
复制代码 请问怎样在 xsl 运用 document() query 这三个xml date,然后 apply-templates ? |
|
|
|
|
|
|
|
|
|
|
发表于 19-5-2009 02:41 PM
|
显示全部楼层
你的xml 有点错。
------------------------xml ---------------------------------
<?xml version="1.0"?>
<test>
<train>
<customer>A</customer>
<bus no="BC1243">
<date>12-12-2009</date>
<seat>24A</seat>
</bus>
</train>
<train>
<customer>B</customer>
<bus no="BC1243">
<date>12-12-2009</date>
<seat>24B</seat>
</bus>
</train>
</test>
--------------------------------------------------------------------------------------
---------------------------XSL-------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="html" omit-xml-declaration="yes"/>
<xsl:for-each select="/">
script....................
</xsl:for-each >
<xsl:template match="/test/train/bus/date">
<xsl:value-of select="."/>
</xsl:template>
--------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
发表于 19-5-2009 02:48 PM
|
显示全部楼层
对不起,这才是正确的答案.
------------------------xml ---------------------------------
<?xml version="1.0"?>
<test>
<train>
<customer>A</customer>
<bus no="BC1243">
<date>12-12-2009</date>
<seat>24A</seat>
</bus>
</train>
<train>
<customer>B</customer>
<bus no="BC1243">
<date>12-12-2009</date>
<seat>24B</seat>
</bus>
</train>
</test>
--------------------------------------------------------------------------------------
---------------------------XSL-------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/test/train/bus/date">
<p>
<xsl:value-of select="."/>
</p>
</xsl:template>
</xsl:stylesheet>
--------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|