可行性分析:写一个xsl能否实现如下的显示,并且能打印出来。。。 (100分)

  • 主题发起人 主题发起人 千中元
  • 开始时间 开始时间

千中元

Unregistered / Unconfirmed
GUEST, unregistred user!
TAdodataset.savetofile得到一个xml文件。
能否写一个xsl, 然后打印出来是这样的(以两条记录为例):
Circuit ID: G20121 Data: 24 Nov 99
Test Result: Pass Cable Type: Cat 5 UTP
Test Expected Results Actual Test Results
----------------------------------------------------------------------
| |Pr 12 Pr 36 Pr 45 Pr 78
Attenuation dB| Cat 5 Channel |11.7 11.5 12.9 12.1
Circuit ID: G20123 Data: 24 Nov 99
Test Result: Pass Cable Type: Cat 5 UTP
Test Expected Results Actual Test Results
----------------------------------------------------------------------
| |Pr 12 Pr 36 Pr 45 Pr 78
Attenuation dB| Cat 5 Channel |10.5 10.2 11.7 11.4
 
xml俺不熟悉,如果可行的话利马去看
不行的话,只好想办法做成 。txt文件了
 
没有作过
 
应该可以, 请把那2条记录的 xml 贴出来.
 
我也觉得应该可以:)
 
》应该可以, 请把那2条记录的 xml 贴出来
不好意思,现在连数据库中表结构都没有定下来。主要是考虑
如果要通过xsl能够显示出来,类似Circuit ID,Date,Test Result
等是应该作为字段名,还是将Circuit ID,Date,Test Result等
作为数据保存(如果作为数据,则分别有字段1,字段2,字段3。。,每个字段里面
保留默认值分别为:Circuit ID, Date,Test Result)
 
另外,我看了本书上关于xml的书,
上面讲到如果用xsl的话,必须把一个xsl 链接到xml, 但是
这个xml文件是TadoDataSet.savetofile产生的,不可能包含
链接到哪个xsl文件的信息。。。
 
hmmm... listening
 
你看孙老师的函数:
function load_xml(obj, xmlobj, fnxsl) {
try {
hiddenxml = xmlobj.innerHTML;
var myxml = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
myxml.async = false;
myxml.loadXML(hiddenxml);
var myxsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
myxsl.async = false;
myxsl.load(fnxsl);
html = myxml.transformNode(myxsl);
obj.innerHTML = html;
}
catch (exception) {
obj.innerHTML = exception.description;
}
}
关键在myxml.transformNode(myxsl);
 
avant,
不好意思,不知道如何调用:(
用ie打开该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='c0' rs:name='Circuit Id' rs:number='1' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='Circuit Id'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='Date' rs:number='2' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='Date'>
<s:datatype dt:type='dateTime' rs:dbtype='timestamp' dt:maxLength='16' rs:scale='3' rs:precision='23' rs:fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='c2' rs:name='Test Result' rs:number='3' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='Test Result'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='c3' rs:name='Cable Type' rs:number='4' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='Cable Type'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='Test' rs:number='5' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='Test'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='c5' rs:name='Actual Test Results' rs:number='6' rs:nullable='true' rs:writeunknown='true'
rs:basecatalog='Fiber' rs:basetable='Reports' rs:basecolumn='Actual Test Results'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='Pr12' rs:number='7' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='Pr12'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='pr36' rs:number='8' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='pr36'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='pr45' rs:number='9' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='pr45'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='pr78' rs:number='10' rs:nullable='true' rs:writeunknown='true' rs:basecatalog='Fiber'
rs:basetable='Reports' rs:basecolumn='pr78'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row c0='G20121' Date='1999-11-24T00:00:00' c2='Pass ' c3='cat 5 utp' Test='attenuation dB' c5='Cat 5 UTP '
Pr12='11.7' pr36='11.9' pr45='11.6' pr78='11.8'/>
<z:row c0='G20122' Date='1999-11-24T00:00:00' c2='pass ' c3='cat 5 utp' Test='attenuation dB' c5='Cat 5 UTP '
Pr12='16.3' pr36='16.1' pr45='16.4' pr78='16.2'/>
</rs:data>
</xml>
 
>>打印出来是这样
你怎么打印呀?
转化成HTML用IE打印?
转化成文本格式打印?
用xsl都可行的.作为load_xml的第三个参数.
 
XSL 文件如下:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"
xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema"
xmlns:user="http://mycompany.com/mynamespace"
xmlns:dt="urn:schemas-microsoft-com:datatypes"
>
<xsl:script language="JScript"><![CDATA[
function leftformat(strX , nlen)
{
while (strX.length < nlen)
{
strX += ' '
}
return strX
}
function rightformat(strX , nlen)
{
while (strX.length < nlen)
{
strX = ' ' + strX
}
return strX
}
]]>
</xsl:script>
<!--
<xsl:output method="text" version="1.0" indent="yes" ></xsl:output>
-->
<xsl:template match="/">
<xsl:apply-templates select="xml/rs:data/z:row"/>
</xsl:template>

<xsl:template match="xml/rs:data/z:row" >
<xsl:apply-templates select="@c0"/><xsl:apply-templates select="@Date"/>
<xsl:apply-templates select="@c2"/><xsl:apply-templates select="@c3"/>
<![CDATA[Test Expected Results Actual Test Results
----------------------------------------------------------------------
| |Pr 12 Pr 36 Pr 45 Pr 78
]]><xsl:apply-templates select="@Test"/>| <xsl:apply-templates select="@c5"/>|<xsl:apply-templates select="@Pr12"/> <xsl:apply-templates select="@pr36"/> <xsl:apply-templates select="@pr45"/> <xsl:apply-templates select="@pr78"/><![CDATA[
]]>
</xsl:template>
<xsl:template match="@c0">Circuit ID: <xsl:eval>leftformat(this.value, 15)</xsl:eval></xsl:template>
<xsl:template match="@Date">Date: <xsl:eval>leftformat(this.value,20)</xsl:eval>
</xsl:template>
<xsl:template match="@c2">Test Result: <xsl:eval>leftformat(this.value,15)</xsl:eval></xsl:template>
<xsl:template match="@c3">Cable Type: <xsl:eval>leftformat(this.value,20)</xsl:eval>
</xsl:template>
<xsl:template match="@Test"><xsl:eval>leftformat(this.value,17)</xsl:eval></xsl:template>
<xsl:template match="@c5"><xsl:eval>leftformat(this.value,23)</xsl:eval></xsl:template>
<xsl:template match="@Pr12|@pr36|@pr45|@pr78"><xsl:eval>formatNumber(this.value," ####.0 ")</xsl:eval></xsl:template>
</xsl:stylesheet>
 
多人接受答案了。
 

Similar threads

H
回复
27
查看
2K
athene
A
后退
顶部