【发布时间】:2018-11-12 02:01:33
【问题描述】:
我正在使用 LandXML 创建下表,但我想填充纬度和经度而不是北距和东距值。
我知道 AlignPI 具有如下所示的属性和嵌套属性,但我很难集中精力访问它们并将它们放入实际表中。 [AlignPIs属性映射][3]
这就是我目前的代码
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:lx="http://www.landxml.org/schema/LandXML-1.2" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:landUtils="http://www.autodesk.com/land/civil/vcedit"
xmlns:lxml="urn:lx_utils">
<!--Description:Tabulation of Alignment PI with Station, Latitude and Longitude.
This form is valid for LandXML 0.88, 1.0, 1.1 and 1.2 data.-->
<!--CreatedBy:Mark Hultgren -->
<!--DateCreated:06/01/2018 -->
<!--LastModifiedBy:Mark Hultgren -->
<!--DateModified:06/01/2018 -->
<!--OutputExtension:html -->
<xsl:output method="html" encoding="UTF-8" />
<!-- ==== JavaScript Includes ==== -->
<xsl:include href="header.xsl" />
<xsl:include href="UELS_Alignment_Layout.xsl" />
<!--AlignmentPI Parameters-->
<xsl:param name="PINumber" select="//lx:AlignPI/*/@pntRef" />
<xsl:param name="PIStation" select="//lx:AlignPI/*/@Station" />
<xsl:param name="PILatitude" select="//lx:AlignPI/*/@latitude" />
<xsl:param name="PILongitude" select="//lx:AlignPI/*/@longitude" />
<xsl:template match="/">
<xsl:for-each select="AlignPIs" test="//lx:AlignPI/*/@PI">
<!--if there is diameterUnit, use it as pipe diameter dimension unit-->
<xsl:value-of select="//lx:Units/*/@diameterUnit" />
</xsl:for-each>
<xsl:otherwise>
<!--otherwise, use linearUnit-->
<xsl:value-of select="//lx:Units/*/@linearUnit" />
</xsl:otherwise>
</xsl:template>
</xsl:param>
<!-- ============================= -->
<xsl:template match="/">
<html>
<head>
<title>Alignment PI Station report with Latitude and Longitude<br/> for <xsl:value-of select="//lx:Project/@name" /></title>
<style type="text/css">
div{
width:10.5in;
font-family:Verdana;
}
th{
font-size:12pt;
text-align:center;
text-decoration:underline;
}
td{
padding:0.02in 0.15in;
text-align:right;
}
tr{
font-size:10pt;
}
</style>
</head>
<body>
<div>
<xsl:call-template name="AutoHeader">
<xsl:with-param name="ReportTitle">Alignment PI Report</xsl:with-param>
<xsl:with-param name="ReportDesc">
<xsl:value-of select="//lx:Project/@name" />
</xsl:with-param>
</xsl:call-template>
<br />
<xsl:for-each select="//lx:Alignment/lx:AlignPIs">
<b>Alignment: <xsl:value-of select="@name" /></b>
<br />Project Name [(Edit This)]
<table bordercolor="black" border="1" cellspacing="0" width="100%">
<tr>
<th>ID</th>
<th>Station</th>
<th>Latitude</th>
<th>Longitude</th>
</tr>
<xsl:for-each select="./lx:AlignPIs/lx:AlignPI">
<tr>
<xsl:variable name="PINumber" select="pntRef/@text()"
<xsl:variable name="Station" select="AlignPI/@Station" />
<xsl:variable name="PI" select="latitude" />
<xsl:variable name="PI" select="longitude" />
<td>
<xsl:value-of select="$PINumber" />
</td>
<td>
<xsl:value-of select="$Station" />
</td>
<td>
<xsl:value-of select="$latitude" />
</td>
<td>
<xsl:value-of select="$longitude" />
</td>
</xsl:for-each>
</table>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
【问题讨论】:
标签: xml xslt xpath transformation