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
Xml 删除空间XSLT_Xml_Xslt_Kml - Fatal编程技术网

Xml 删除空间XSLT

Xml 删除空间XSLT,xml,xslt,kml,Xml,Xslt,Kml,我发现很多帖子都与我的问题有关,但解决方案不起作用 我的输入中有许多XML元素,我想生成一个KML文件。对于KML描述,我使用CDATA。在这个CDATA中,我尝试放置一个 “/img ]] 该代码生成以下结果: <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text> <xsl:text disable-output-escaping="yes"

我发现很多帖子都与我的问题有关,但解决方案不起作用

我的输入中有许多XML元素,我想生成一个KML文件。对于KML描述,我使用CDATA。在这个CDATA中,我尝试放置一个

“/img
]]
该代码生成以下结果:

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                    <xsl:text disable-output-escaping="yes">   
                         &lt;p&gt;The &lt;a href="http://en.wikipedia.org/wiki/Fremont_Troll">Fremont Troll&lt;/a&gt; is a large concrete sculpture &lt;br/&gt;
                            of the mythical troll who lives under the bridge.&lt;/p&gt;
                             &lt;p&gt;The troll is holding a Volkswagen bug in his hand.&lt;/p&gt;
                                &lt;img src="http://client.thomasblasig.fr/KML_images  
                    </xsl:text>
            <xsl:variable name="link_image" select="$images/circuits/circuit[@id=$id_circuit]/image[@etape=$id_etape]/lien"></xsl:variable>
            <xsl:variable name="new_link_image" select="replace($link_image, './', '/')"></xsl:variable>        
            <xsl:value-of select="translate($new_link_image, ' ', '')"></xsl:value-of>
                    <xsl:text disable-output-escaping="yes">    
                                "&gt;&lt;/img&gt;
                    </xsl:text>
              <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>

1号Etape:居里大道
这是一个巨大的混凝土雕塑,是一个住在桥下的神秘巨魔。

巨魔手里拿着一只大众汽车的虫子。

]]> -74.006393,40.714172,0

如您所见,my
和my
之间存在空格。我如何删除它们?

我猜您所说的空格,是在输出中的
img
标记中出现的空格:

<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Placemark>
<name>Etape n° 1 : Avenue Joliot Curie</name>
<description>
<![CDATA[
<p>The <a href="http://en.wikipedia.org/wiki/Fremont_Troll">Fremont Troll</a> is a large concrete sculpture <br/> of the mythical troll who lives under the bridge.</p> <p>The troll is holding a Volkswagen bug in his hand.</p> <img src="http://client.thomasblasig.fr/KML_images /image/02.jpg "></img>
]]>
</description>
<Point>
<coordinates>-74.006393,40.714172,0</coordinates>
</Point>
</Placemark>
…确实需要这样写:

<xsl:text disable-output-escaping="yes">    
    "&gt;&lt;/img&gt;
</xsl:text>
<>请注意,您可能会考虑重新编写XSLT,使之具有可读性。
&lt;img src="http://client.thomasblasig.fr/KML_images</xsl:text>

你做错了。像实际的XML一样嵌入KML,而不是像任意文本一样嵌入KML。你可能希望显示更多的XSLT(一个自包含的工作示例,作为开始)还有您的输入XML。我这样做是因为我无法访问CDATA标记。但是,对不起,我不清楚您对此问题的建议。您的解决方案有效,我不理解CDATA标记。非常感谢。
<xsl:text disable-output-escaping="yes">"&gt;&lt;/img&gt;</xsl:text>
&lt;img src="http://client.thomasblasig.fr/KML_images</xsl:text>
    <description>
    <![CDATA[<p>The <a href="http://en.wikipedia.org/wiki/Fremont_Troll">Fremont Troll</a> is a large concrete sculpture <br/>
            of the mythical troll who lives under the bridge.</p>
            <p>The troll is holding a Volkswagen bug in his hand.</p>
            <img src="http://client.thomasblasig.fr/KML_images]]><xsl:value-of select="translate($new_link_image, ' ', '')" /><![CDATA["></img>]]>
    </description>
<xsl:output method="xml" indent="yes" cdata-section-elements="description" />