Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
html表xslt中div的总数_Html_Xslt_Html Table_Counting - Fatal编程技术网

html表xslt中div的总数

html表xslt中div的总数,html,xslt,html-table,counting,Html,Xslt,Html Table,Counting,我需要帮助计算表中的div,我需要整个表中的sum div,并将sum结果放在表下。以下是我的表输出: <html> <body> <h2>Designated Points</h2> <table border="1"> <tr bgcolor="#9acd32">

我需要帮助计算表中的div,我需要整个表中的sum div,并将sum结果放在表下。以下是我的表输出:

<html>
          <body>
             <h2>Designated Points</h2>
                <table border="1">
                    <tr bgcolor="#9acd32">
                        <th>Coordinates</th>
                        <th>NAME</th>
                    </tr>
                    <tr>
                        <td><div>51.111217 4.5630126</div></td>
                        <td>EKELEE</td>
                    </tr>
                    <tr>
                        <td>
                            <div>50.8527128 3.1472122</div></td>
                        <td>EB1212S14</td>
                    </tr>
                    <tr>
                        <td>
                            <div>50.4812972 3.811225</div><br>
                             <div>50.4351228 3.9531289</div><br>
                             <div>50.5012278 3.912425</div><br>
                             <div>50.5312528 3.9312611</div><br>
                             <div>50.63806 3.66167</div><br>
                             <div>50.6231289 3.6461211</div><br>
                             <div>50.5121722 3.731275</div><br>
                             <div>50.4128972 3.811225</div><br>
        </td>
         </tr>
                </table>
            </body>
        </html>

指定点
协调
名称
51.111217 4.5630126
埃克利
50.8527128 3.1472122
EB1212S14
50.4812972 3.811225
50.4351228 3.9531289
50.5012278 3.912425
50.5312528 3.9312611
50.63806 3.66167
50.6231289 3.6461211
50.5121722 3.731275
50.4128972 3.811225
谢谢你的帮助

这是我的输入,我不知道如何在不同的模板中计算表中的所有div:

<xsl:template match="/">
        <html>
            <body>
                <h2>Designated Points</h2>
                <table border="1">
                    <tr bgcolor="#9acd32">
                        <th>Coordinates</th>
                        <th>Designator</th>
                    </tr>

    <xsl:for-each select="message:AIXMBasicMessage/message:hasMember/aixm:Airspace/aixm:timeSlice/aixm:AirspaceTimeSlice">

    <tr>
        <td>
             <xsl:for-each select=".//gml:pos">
                <div>   
                    <xsl:value-of select="."/>
              </div>    
              </xsl:for-each>

                <xsl:for-each select=".//gml:posList">   
                    <xsl:call-template name="split"/>   
               </xsl:for-each>
       </td>    

       <td> 
         <xsl:value-of select="aixm:designator"/>    
       </td>

     </tr>
    </xsl:for-each>
   </table>
  </body>
 </html>

</xsl:template>

<xsl:template match="table" name="count">
<xsl:copy-of select="."/>
<xsl:value-of select="count(.//div)"/>
</xsl:template>


    <xsl:template match="text()" name="split">
        <xsl:param name="pText" select="."/>
        <xsl:if test="normalize-space($pText)">
            <xsl:variable name="vText" select="concat(normalize-space($pText), ' ')"/>

            <div>    
            <xsl:value-of select="substring-before($vText, ' ')"/>
            <xsl:value-of select="concat(' ', substring-before(substring-after($vText, ' '), ' '), '&#xA;')"/>
              </div>
            <br/>
            <xsl:call-template name="split">
                <xsl:with-param name="pText" select="substring-after(substring-after($vText, ' '), ' ')"/>
            </xsl:call-template>

        </xsl:if>
    </xsl:template> 

指定点
协调
指示符

我需要计算gml:pos中的每个点和gml:posList中的每个分割点

这是一个伪造的数据:

<?xml version="1.0" encoding="UTF-8"?> <AIXMBasicMessage
 xmlns="http://www.aixm.aero/schema/5.1/message"
 xmlns:gml="http://www.opengis.net/gml/3.2"
 xmlns:aixm="http://www.aixm.aero/schema/5.1"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:gts="http://www.isotc211.org/2005/gts"
 xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:adr="http://www.aixm.aero/schema/5.1/extensions/EUR/ADR"
 xmlns:gmd="http://www.isotc211.org/2005/gmd"
 xmlns:xlink="http://www.w3.org/1999/xlink" gml:id="uniqueId"
 xsi:schemaLocation="http://www.aixm.aero/schema/5.1/message
 http://www.aixm.aero/schema/5.1/message/AIXM_BasicMessage.xsd
 http://www.aixm.aero/schema/5.1/extensions/EUR/ADR
 http://www.aixm.aero/schema/5.1/extensions/EUR/ADR18.5/ADR_Features.xsd">
 <hasMember>        <aixm:Airspace
 xmlns="http://www.aixm.aero/schema/5.1/message"
 gml:id="uuid.b6950093-ae6d-4ef4-b7bf-c30074810e72">            <gml:identifier
 codeSpace="urn:uuid:">b6950093-ae6d-4ef4-b7bf-c30074810e72</gml:identifier>
            <gml:boundedBy xsi:nil="true"/>             <aixm:timeSlice owns="false">
                <aixm:AirspaceTimeSlice gml:id="uuid.d3c353b4-0bbc-4035-91df-24b342c56497">
                    <gml:validTime xlink:type="simple" owns="false">
                        <gml:TimePeriod gml:id="uuid.d3065abe-6c92-4da0-8455-e498b70f48d1" frame="#ISO-8601">
                            <gml:beginPosition frame="#ISO-8601">2015-06-25T00:00:00Z</gml:beginPosition>
                            <gml:endPosition indeterminatePosition="unknown" frame="#ISO-8601"/>
                        </gml:TimePeriod>
                    </gml:validTime>
                    <aixm:interpretation>BASELINE</aixm:interpretation>
                    <aixm:sequenceNumber>2</aixm:sequenceNumber>
                    <aixm:correctionNumber>0</aixm:correctionNumber>
                    <aixm:featureLifetime xlink:type="simple" owns="false">
                        <gml:TimePeriod gml:id="uuid.738e81ce-7c9b-471f-bf49-2d30efb712d5" frame="#ISO-8601">
                            <gml:beginPosition frame="#ISO-8601">2007-08-02T00:00:00Z</gml:beginPosition>
                            <gml:endPosition indeterminatePosition="unknown" frame="#ISO-8601"/>
                        </gml:TimePeriod>
                    </aixm:featureLifetime>
                    <aixm:type>D_OTHER</aixm:type>
                    <aixm:designator>EDFL</aixm:designator>
                    <aixm:name>FGDF</aixm:name>
                    <aixm:designatorICAO>NO</aixm:designatorICAO>
                    <aixm:controlType>CIVIL</aixm:controlType>
                    <aixm:geometryComponent>
                        <aixm:AirspaceGeometryComponent gml:id="uuid.ab5ac3fb-bf03-4128-86df-35061368215c">
                            <aixm:theAirspaceVolume>
                                <aixm:AirspaceVolume gml:id="uuid.944b396c-8f92-45d3-a14c-1d02d2d39c87">
                                    <aixm:upperLimit uom="FL">40</aixm:upperLimit>
                                    <aixm:upperLimitReference>STD</aixm:upperLimitReference>
                                    <aixm:lowerLimit uom="FT">3510</aixm:lowerLimit>
                                    <aixm:lowerLimitReference>MSL</aixm:lowerLimitReference>
                                    <aixm:horizontalProjection>
                                        <aixm:Surface xsi:type="aixm:ElevatedSurfaceType" gml:id="uuid.17a135e0-8e6d-4086-aae1-8ee552b4cd00">
                                            <gml:patches>
                                                <gml:PolygonPatch interpolation="planar">
                                                    <gml:exterior>
                                                        <gml:Ring>
                                                            <gml:curveMember xlink:type="simple" owns="false">
                                                                <gml:Curve xsi:type="aixm:CurveType" srsName="urn:ogc:def:crs:EPSG::4326"
 gml:id="uuid.5faf7d1e-e0f6-484c-a4cc-965341d5a780">
                                                                    <gml:segments>
                                                                        <gml:ArcByCenterPoint interpolation="circularArcCenterPointWithRadius" numArc="1"
 numDerivativesAtStart="0" numDerivativesAtEnd="0"
 numDerivativeInterior="0">
                                                                            <gml:pos>51.165 4.181289</gml:pos>
                                                                            <gml:radius uom="[nmi_i]">40.0</gml:radius>
                                                                            <gml:startAngle uom="deg">121.451258936276643</gml:startAngle>
                                                                            <gml:endAngle uom="deg">134.6012057585252537</gml:endAngle>
                                                                        </gml:ArcByCenterPoint>
                                                                        <gml:GeodesicString interpolation="geodesic" numDerivativesAtStart="0" numDerivativesAtEnd="0"
 numDerivativeInterior="0">
                                                                            <gml:posList>50.69389 4.9312417 50.7122806 4.86556 50.7129444 4.9175</gml:posList>
                                                                        </gml:GeodesicString>
                                                                        <gml:ArcByCenterPoint interpolation="circularArcCenterPointWithRadius" numArc="1"
 numDerivativesAtStart="0" numDerivativesAtEnd="0"
 numDerivativeInterior="0">
                                                                            <gml:pos>50.78167 4.95778</gml:pos>
                                                                            <gml:radius uom="[nmi_i]">1.7</gml:radius>
                                                                            <gml:startAngle uom="deg">296.6484324915256</gml:startAngle>
                                                                            <gml:endAngle uom="deg">357.5095314492478</gml:endAngle>
                                                                        </gml:ArcByCenterPoint>
                                                                        <gml:GeodesicString interpolation="geodesic" numDerivativesAtStart="0" numDerivativesAtEnd="0"
> numDerivativeInterior="0">
                                                                            <gml:posList>50.81 4.95583 50.1281333 5.08472</gml:posList>
                                                                        </gml:GeodesicString>
                                                                    </gml:segments>
                                                                </gml:Curve>
                                                            </gml:curveMember>
                                                        </gml:Ring>
                                                    </gml:exterior>
                                                </gml:PolygonPatch>
                                            </gml:patches>
                                        </aixm:Surface>
                                    </aixm:horizontalProjection>
                            </aixm:AirspaceVolume>
                            </aixm:theAirspaceVolume>
                        </aixm:AirspaceGeometryComponent>
                    </aixm:geometryComponent>
                </aixm:AirspaceTimeSlice>           </aixm:timeSlice>       </aixm:Airspace>    </hasMember>    </AIXMBasicMessage>

b6950093-ae6d-4ef4-b7bf-c30074810e72
2015-06-25T00:00:00Z
基线
2.
0
2007-08-02T00:00:00Z
D_其他
EDFL
FGDF
不
公民的
40
性病科
3510
MSL
51.165 4.181289
40
121.451258936276643
134.6012057585252537
50.69389 4.9312417 50.7122806 4.86556 50.7129444 4.9175
50.78167 4.95778
1.7
296.6484324915256
357.5095314492478
numDerivativeInterior=“0”>
50.81 4.95583 50.1281333 5.08472
--根据澄清进行编辑--

我建议你这样做:

<xsl:variable name="count-points">
    <xsl:for-each select="/message:AIXMBasicMessage/message:hasMember/aixm:Airspace/aixm:timeSlice/aixm:AirspaceTimeSlice//gml:pos">
        <n>1</n>
    </xsl:for-each>
    <xsl:for-each select="/message:AIXMBasicMessage/message:hasMember/aixm:Airspace/aixm:timeSlice/aixm:AirspaceTimeSlice//gml:posList">
        <xsl:variable name="spaces" select="translate(normalize-space(.), '0123.456789.', '')" />
        <n>
            <xsl:value-of select="ceiling(string-length($spaces) div 2)"/>
        </n>
    </xsl:for-each>
</xsl:variable>     

<p>Count of Points: <xsl:value-of select="sum(exsl:node-set($count-points)/n)"/></p>

注意:您试图对输出中的
div
元素进行计数的尝试无法工作;XSLT处理输入XML,但无权访问自己的输出


补充: 这里有一种解决整个问题的替代方法,它消除了亲
xmlns:exsl="http://exslt.org/common"
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:message="http://www.aixm.aero/schema/5.1/message"
xmlns:gml="http://www.opengis.net/gml/3.2" 
xmlns:aixm="http://www.aixm.aero/schema/5.1" 
xmlns:exsl="http://exslt.org/common"
exclude-result-prefixes="message gml aixm exsl">
<xsl:output method="html" encoding="UTF-8"/>

<xsl:template match="/">
    <!-- first-pass -->
    <xsl:variable name="points">
        <xsl:for-each select="message:AIXMBasicMessage/message:hasMember/aixm:Airspace/aixm:timeSlice/aixm:AirspaceTimeSlice">
            <group designator="{aixm:designator}">
                <xsl:for-each select=".//gml:pos">
                    <point>
                        <xsl:value-of select="."/>
                    </point>
                </xsl:for-each>
                <xsl:for-each select=".//gml:posList">
                    <xsl:call-template name="split"/>
                </xsl:for-each>
            </group>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="points-set" select="exsl:node-set($points)" />
    <!-- output -->
    <html>
        <body>
            <h2>Designated Points</h2>
            <table border="1">
                <tr bgcolor="#9acd32">
                    <th>Designator</th>
                    <th>Coordinates</th>
                </tr>
                <xsl:for-each select="$points-set/group">
                    <tr>
                        <td rowspan="{count(point) + 1}">
                            <xsl:value-of select="@designator"/>
                        </td>
                    </tr>
                    <xsl:for-each select="point">
                        <tr>
                            <td>
                                <xsl:value-of select="."/>
                            </td>
                        </tr>
                    </xsl:for-each>
                </xsl:for-each>
            </table>
            <p>Count of Points: <xsl:value-of select="count($points-set//point)"/></p>
        </body>
    </html>
</xsl:template>

<xsl:template name="split">
    <xsl:param name="text" select="normalize-space(.)"/>
    <xsl:if test="string($text)">
        <point>
            <xsl:value-of select="substring-before($text, ' ')"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="substring-before(substring-after(concat($text, ' '), ' '), ' ')"/>
        </point>
        <xsl:call-template name="split">
            <xsl:with-param name="text" select="substring-after(substring-after($text, ' '), ' ')"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>


</xsl:stylesheet>