我有一個XSLT,它具有將KML重新格式化爲GML的工作。將KML xmlns屬性從KML衝突到XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.opengis.net/gml" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" exclude-result-prefixes="kml">
<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="yes" />
<!-- Removes all nodes with any empty text -->
<xsl:template match="*[.='']"/>
<!-- Removes all nodes with any empty attribute -->
<xsl:template match="*[@*='']"/>
<xsl:template match="text()"/>
<xsl:template match="/">
<MultiSurface>
<surfaceMembers>
<xsl:apply-templates />
</surfaceMembers>
</MultiSurface>
</xsl:template>
<xsl:template match="kml:Placemark">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="kml:Point">
<!--<Point>
<xsl:apply-templates />
</Point>-->
</xsl:template>
<xsl:template match="kml:LineString">
<!--<LineString>
<xsl:apply-templates />
</LineString>-->
</xsl:template>
<xsl:template match="kml:Polygon">
<Polygon>
<xsl:apply-templates />
</Polygon>
</xsl:template>
<xsl:template match="kml:outerBoundaryIs">
<exterior>
<xsl:apply-templates />
</exterior>
</xsl:template>
<xsl:template match="kml:innerBoundaryIs">
<interior>
<xsl:apply-templates />
</interior>
</xsl:template>
<xsl:template match="kml:LinearRing">
<LinearRing>
<xsl:apply-templates />
</LinearRing>
</xsl:template>
<xsl:template match="kml:coordinates">
<posList>
<!--<xsl:value-of select="translate(., ',', ' ')" />-->
<xsl:call-template name="output-tokens">
<xsl:with-param name="list" select="." />
</xsl:call-template>
</posList>
</xsl:template>
<xsl:template name="output-tokens">
<xsl:param name="list" />
<xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />
<xsl:variable name="first" select="substring-before($newlist, ' ')" />
<xsl:variable name="remaining" select="substring-after($newlist, ' ')" />
<!-- long, lat, alt-->
<xsl:variable name="long" select="substring-before($first, ',')" />
<xsl:choose>
<xsl:when test="contains(substring-after($first, ','), ',')">
<xsl:variable name="lat" select="substring-before(substring-after($first, ','), ',')" />
<xsl:value-of select="concat($lat, ' ', $long, ' ')" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="lat" select="substring-after($first, ',')" />
<xsl:value-of select="concat($lat, ' ', $long, ' ')" />
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$remaining">
<xsl:call-template name="output-tokens">
<xsl:with-param name="list" select="$remaining" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
通常我們的客戶給了我們,有一個KML打開標籤這樣的KML文件:
<kml xmlns="http://www.opengis.net/kml/2.2">
而且此實例的XSLT的偉大工程,以變換KML文件。 http://www.opengis.net/kml/2.2或可替代的XSLT文件的xmlns:KML是未設置爲:http://earth.google.com/kml/2.2但是我們一個今天已經......
<kml xmlns="http://earth.google.com/kml/2.2">...</kml>
這不工作,我想這是因爲的KML xmlns屬性沒有被設置到了
我嘗試以下,但它沒有工作
xmlns:kml="http://www.opengis.net/kml/2.2 http://earth.google.com/kml/2.2"
我覺得答案是愚蠢簡單,但我還沒有碰到過這還迷迷糊糊,我跑出來的東西,嘗試和谷歌。你們有什麼建議?
你確定唯一的區別是命名空間嗎?如果是這樣,請考慮編寫第一個樣式表或樣式表步驟,將命名空間標準化爲您所期望的。 –
請從處理器中顯示XSLT錯誤,因爲*這不起作用*是無用的。 – Parfait