[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Xpath Syntax Issue


Subject: Re: [xsl] Xpath Syntax Issue
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sun, 24 Jun 2012 18:35:15 +0200

Nathan Tallman wrote:
Sorry, here's my XSLT (remove.xsl):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:s="http://www.sitemaps.org/schemas/sitemap/0.9"
     exclude-result-prefixes="s"


<xsl:output method="xml" encoding="UTF-8" indent="yes"/>


<xsl:strip-space elements="*"/>

     <!-- Standard copy -->
     <xsl:template match="*">
         <xsl:copy>
             <xsl:copy-of select="@*"/>
             <xsl:apply-templates/>
         </xsl:copy>
     </xsl:template>

<xsl:template match="s:urlset/s:url[normalize-space(s:loc) = 'URL']"/>

</xsl:stylesheet>

XML Snippet (sitemap1.xml):
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
      http://www.sitemaps.org/schemas/sitemap/0.9
      http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

      <url>
           <loc>URL</loc>
           <lastmod>2012-06-23T13:37:27+00:00</lastmod>
           <changefreq>monthly</changefreq>
           <priority>1.0</priority>
      </url>
      ....
</urlset>

Command used in Linux:
xsltproc -o sitemapb.xml remove.xsl sitemap1.xml

When I run xsltproc here on the command line with your samples I get



<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
....
</urlset>


so that element has been removed.

Are you getting a different result?

I tried with

Using libxml 20707, libxslt 10126 and libexslt 815
xsltproc was compiled against libxml 20706, libxslt 10126 and libexslt 815
libxslt 10126 was compiled against libxml 20706
libexslt 815 was compiled against libxml 20706

on Windows.




--


	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/


Current Thread
Keywords