我尝试为xml文件创建动态表,但可以打印数据。你能帮忙纠正吗?
<xsl:template match="PageContents">
<!-- Apply a template for each shape that isn't
a Dynamic Connector. The shape's information
will display as a row of the table. -->
<xsl:choose>
<xsl:when test="/PageContents/Shapes/Row[@N ='Dynamic connector']">
<xsl:apply-templates select="/PageContents/Shapes">
<xsl:sort select="not(Row[@N ='Environment']/Cell[@V ='QA'])"/>
<xsl:sort select="not(Row[@N ='Environment']/Cell[@V ='Development'])"/>
<xsl:sort select="not(Row[@N ='Environment']/Cell[@V ='Production'])"/>
<xsl:sort select="Row[@N ='Environment']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='Topology_Reference_Number']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='Role']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='Location']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='SBB_Name']/Cell[@V]" order="ascending"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<!-- The Visio drawing does not have any
Dynamic Connectors. -->
<xsl:apply-templates select="/PageContents/Shapes">
<xsl:sort select="not(Row[@N ='Environment']/Cell[@V ='QA'])"/>
<xsl:sort select="not(Row[@N ='Environment']/Cell[@V ='Development'])"/>
<xsl:sort select="not(Row[@N ='Environment']/Cell[@V ='Production'])"/>
<xsl:sort select="Row[@N ='Environment']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='Topology_Reference_Number']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='Role']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='Location']/Cell[@V]" order="ascending"/>
<xsl:sort select="Row[@N ='SBB_Name']/Cell[@V]" order="ascending"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
PFB样本XML数据(抱歉无法附上完整的表格)。
<?xml version="1.0" encoding="utf-8" ?>
- <PageContents xmlns="http://schemas.microsoft.com/office/visio/2012/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xml:space="preserve">
- <Shapes>
- <Shape ID="1" NameU="itsgShapeQA" IsCustomNameU="1" Name="itsgShapeQA" IsCustomName="1" Type="Shape" LineStyle="6" FillStyle="6" TextStyle="6">
<Cell N="PinX" V="2.525" />
<Cell N="PinY" V="11.155" />
<Cell N="Width" V="1" U="IN" />
<Cell N="Height" V="0.1" U="IN" />
<Cell N="LocPinX" V="0.5" U="IN" F="Width*0.5" />
<Cell N="LocPinY" V="0.05" U="IN" F="Height*0.5" />
<Cell N="Angle" V="0" />
<Cell N="FlipX" V="0" />
<Cell N="FlipY" V="0" />
<Cell N="ResizeMode" V="0" />
<Cell N="EventDblClick" V="0" F="RUNMACRO("TAF___Visio_Template.ThisDocument.ITSGLabel_Click(QA)")" />
<Cell N="LockWidth" V="1" />
<Cell N="LockHeight" V="1" />
<Cell N="LockMoveX" V="1" />
<Cell N="LockMoveY" V="1" />
<Cell N="LockDelete" V="1" />
<Cell N="LockRotate" V="1" />
<Cell N="LeftMargin" V="0.1111111111111111" U="PT" />
- <Section N="Character">
- <Row IX="0">
<Cell N="Color" V="#0b0b0b" F="HSL(0,0,10)" />
<Cell N="Size" V="0.1666666666666667" U="PT" />
</Row>
</Section>
<Section N="Geometry" IX="0">
`enter code here`<Cell N="NoFill" V="1" />
<Cell N="NoLine" V="1" />
<Cell N="NoShow" V="0" />
<Cell N="NoSnap" V="0" />
<Cell N="NoQuickDrag" V="0" />
- <Row T="MoveTo" IX="1">
<Cell N="X" V="0" U="IN" F="Width*0" />
<Cell N="Y" V="0" U="IN" F="Height*0" />
</Row>
- <Row T="LineTo" IX="2">
<Cell N="X" V="1" U="IN" F="Width*1" />
<Cell N="Y" V="0" U="IN" F="Height*0" />
</Row>
- <Row T="LineTo" IX="3">
<Cell N="X" V="1" U="IN" F="Width*1" />
<Cell N="Y" V="0.1" U="IN" F="Height*1" />
</Row>
- <Row T="LineTo" IX="4">
<Cell N="X" V="0" U="IN" F="Width*0" />
<Cell N="Y" V="0.1" U="IN" F="Height*1" />
</Row>
- <Row T="LineTo" IX="5">
<Cell N="X" V="0" U="IN" F="Geometry1.X1" />
<Cell N="Y" V="0" U="IN" F="Geometry1.Y1" />
</Row>
</Section>
<Text />
</Shape>
<Shape ID="2" Type="Foreign" LineStyle="2" FillStyle="2" TextStyle="2" UniqueID="{DD01F26B-EABE-4B44-ABE4-1697851137B5}">
<Cell N="PinX" V="4.251968503937007" />
<Cell N="PinY" V="6.872303556765976" />
<Cell N="Width" V="1.501223284589427" />
<Cell N="Height" V="3.350906326130379" />
<Cell N="LocPinX" V="0.7506116422947136" F="Width*0.5" />
<Cell N="LocPinY" V="1.675453163065189" F="Height*0.5" />
<Cell N="Angle" V="0" />
<Cell N="FlipX" V="0" />
<Cell N="FlipY" V="0" />
<Cell N="ResizeMode" V="0" />
<Cell N="ImgOffsetX" V="0" F="ImgWidth*0" />
<Cell N="ImgOffsetY" V="0" F="ImgHeight*0" />
<Cell N="ImgWidth" V="1.501223284589427" F="Width*1" />
<Cell N="ImgHeight" V="3.350906326130379" F="Height*1" />
<Cell N="ClippingPath" V="" F="No Formula" />
<Cell N="TxtPinX" V="0.7506116422947136" F="Width*0.5" />
<Cell N="TxtPinY" V="0" F="Height*0" />
<Cell N="TxtWidth" V="1.501223284589427" F="Width*1" />
<Cell N="TxtHeight" V="0" F="Height*0" />
<Cell N="TxtLocPinX" V="0.7506116422947136" F="TxtWidth*0.5" />
<Cell N="TxtLocPinY" V="0" F="TxtHeight*0.5" />
<Cell N="TxtAngle" V="0" />
<Cell N="VerticalAlign" V="0" />
- <Section N="Geometry" IX="0">
<Cell N="NoFill" V="0" />
<Cell N="NoLine" V="0" />
<Cell N="NoShow" V="0" />
<Cell N="NoSnap" V="0" />
<Cell N="NoQuickDrag" V="0" />
- <Row T="MoveTo" IX="1">
<Cell N="X" V="0" F="Width*0" />
<Cell N="Y" V="0" F="Height*0" />
</Row>
- <Row T="LineTo" IX="2">
<Cell N="X" V="1.501223284589427" F="Width*1" />
<Cell N="Y" V="0" F="Height*0" />
</Row>
- <Row T="LineTo" IX="3">
<Cell N="X" V="1.501223284589427" F="Width*1" />
<Cell N="Y" V="3.350906326130379" F="Height*1" />
</Row>
- <Row T="LineTo" IX="4">
<Cell N="X" V="0" F="Width*0" />
<Cell N="Y" V="3.350906326130379" F="Height*1" />
</Row>
- <Row T="LineTo" IX="5">
<Cell N="X" V="0" F="Width*0" />
<Cell N="Y" V="0" F="Height*0" />
</Row>
</Section>
XML有多行,行数不断变化,我需要附加所有这些数据
谢谢!
答案 0 :(得分:1)
PageContents元素位于命名空间中,但是您在没有命名空间的情况下匹配PageContents元素。
在此网站或Google上搜索“XSLT默认命名空间”,其中有数百篇帖子向您展示如何解决此问题。