倾家荡产求一解,可能很简单,大家帮忙!(xml问题) (67分)

  • 主题发起人 主题发起人 cfx
  • 开始时间 开始时间
C

cfx

Unregistered / Unconfirmed
GUEST, unregistred user!
题目:我把ADOQUERY的数据集保存成XML文件,我想写一个XSL把该文件转化成HTML显示,
大家帮忙啊!
XML文件如下(换行不利于看清文件结构,所以不换行,见晾):
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:updatable='true'>
<s:AttributeType name='cid' rs:number='1' rs:writeunknown='true' rs:basecatalog='ajmanage' rs:basetable='Document'
rs:basecolumn='cid'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>
</s:AttributeType>
<s:AttributeType name='mo_num' rs:number='2' rs:writeunknown='true' rs:basecatalog='ajmanage' rs:basetable='Document'
rs:basecolumn='mo_num'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='13' rs:maybenull='false'/>
</s:AttributeType>
<s:AttributeType name='mo_manager' rs:number='3' rs:writeunknown='true' rs:basecatalog='ajmanage' rs:basetable='Document'
rs:basecolumn='mo_manager'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>
</s:AttributeType>
<s:AttributeType name='mo_natu' rs:number='4' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='ajmanage'
rs:basetable='Document' rs:basecolumn='mo_natu'>
<s:datatype dt:type='i2' dt:maxLength='2' rs:precision='5' rs:fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='be_date' rs:number='5' rs:writeunknown='true' rs:basecatalog='ajmanage' rs:basetable='Document'
rs:basecolumn='be_date'>
<s:datatype dt:type='dateTime' rs:dbtype='timestamp' dt:maxLength='16' rs:scale='3' rs:precision='23' rs:fixedlength='true'
rs:maybenull='false'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row cid='1' mo_num='2002032001' mo_manager='1' mo_natu='0' be_date='2002-03-20T00:00:00'/>
<z:row cid='9' mo_num='2002042701' mo_manager='2' mo_natu='1' be_date='2002-04-27T00:00:00'/>
<z:row cid='10' mo_num='2002051001' mo_manager='1' mo_natu='0' be_date='2002-05-10T00:00:00'/>
<z:row cid='12' mo_num='2002071001' mo_manager='1' mo_natu='0' be_date='2002-05-10T00:00:00'/>
<z:row cid='15' mo_num='200207102' mo_manager='1' mo_natu='0' be_date='2002-06-28T00:00:00'/>
</rs:data>
</xml>
 
靠!!晕啊,,,DFW怎么自动换行了。。NND
 
在 xml 文档的头上加上以下两句:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>
然后用以下的 xsl
myxsl.xsl
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'
version="1.0">
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<xsl:apply-templates select="xml"/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="table">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="rs:data">
<table border='1'>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="z:row">
<tr>
<td><xsl:value-of select="@mo_num"/></td>
<td><xsl:value-of select="@cid"/></td>
<td><xsl:value-of select="@mo_manager"/></td>
<td><xsl:value-of select="@mo_natu"/></td>
<td><xsl:value-of select="@be_date"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
要输出表头,道理是一样的。
 
接受答案了.
 
后退
顶部