Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6197183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:46:29+00:00 2026-05-24T03:46:29+00:00

I have a KML file with country borders <Document> … <Folder> <name>Countries</name> <Style> <ListStyle>

  • 0

I have a KML file with country borders

    <Document>
    ...
        <Folder>
            <name>Countries</name>
            <Style>
                <ListStyle>
                    <listItemType>checkHideChildren</listItemType>
                    <bgColor>00ffffff</bgColor>
                    <maxSnippetLines>2</maxSnippetLines>
                </ListStyle>
            </Style>
            <Folder>
                <name>Labels</name>
                <Placemark>
                    <name>Angola</name>
                    <styleUrl>#NoneIconStyle</styleUrl>
                    <Point>
                        <coordinates>17.5379654426636,-12.2994772211426,0</coordinates>
                    </Point>
                </Placemark>
            ... ignore these

            <Folder>
                <name>A -</name>
                <Placemark>
                    <name>Afghanistan</name>
                    <Polygon>
                        <outerBoundaryIs>
                            <LinearRing>
                                <coordinates>
65.62729644775391,37.33319854736328,0 65.64692687988283,37.45888137817383,0 65.70137023925781,37.53693008422852,0 65.76608276367188,37.53416061401367,0 65.7855224609375,37.56887817382813,0 66.30274963378906,37.32360076904297,0 66.53876495361328,37.36051177978516,0 66.58690643310547,37.36803817749023,0 66.66525268554688,37.33832168579102,0 66.74442291259766,37.36137008666992,0 67.02163696289063,37.37720108032227,0 67.20025634765625,37.24665069580078,0 67.22942352294922,37.19192886352539,0 67.26637268066406,37.18526077270508,0 67.42440795898438,37.23498916625977,0 67.52163696289063,37.27248001098633,0 67.55745697021484,37.21554183959961,0 67.64940643310547,37.24608993530273,0 67.77413940429689,37.20608901977539,0 67.77715301513672,37.18579864501953,0 

It has every country. I want to make a separate files for each country. I want to ignore the initial ‘lables’ folder and move the Folder with the coordinates one up in the tree. So Afghanistan.KML would be

<?xml version="1.0" encoding="UTF-8"?>
<kml>
    <Document>
        <Folder>
            <name>Countries</name>
                <Placemark>
                    <name>Afghanistan</name>
                    <Polygon>
                        <outerBoundaryIs>
                            <LinearRing>
                                <coordinates>
65.62729644775391,37.33319854736328,0 65.64692687988283,37.45888137817383,0 65.70137023925781,37.53693008422852,0 65.76608276367188,37.53416061401367,0 65.7855224609375,37.56887817382813,0 66.30274963378906,37.32360076904297,0 66.53876495361328,37.36051177978516,0 66.58690643310547,37.36803817749023,0 66.66525268554688,37.33832168579102,0 66.74442291259766,37.36137008666992,0 67.02163696289063,37.37720108032227,0 67.20025634765625,37.24665069580078,0 67.22942352294922,37.19192886352539,0 67.26637268066406,37.18526077270508,0 67.42440795898438,37.23498916625977,0 67.52163696289063,37.27248001098633,0 67.55745697021484,37.21554183959961,0 67.64940643310547,37.24608993530273,0 67.77413940429689,37.20608901977539,0 67.77715301513672,37.18579864501953,0 
    ...etc

My XSLT nearly works

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" version="1.0" omit-xml-declaration="yes"/>
    <xsl:template match="/">
        <xsl:apply-templates select="*[local-name()='kml']/*[local-name()='Document']"/>
    </xsl:template>
    <xsl:template match="*[local-name()='kml']/*[local-name()='Document']">
        <Document>
            <xsl:apply-templates select="*[local-name()='Folder']"/>
        </Document>
    </xsl:template>
    <xsl:template match="*[local-name()='Folder']">
        <xsl:apply-templates select="*[local-name()='Folder' or local-name()='Placemark']"/>
    </xsl:template>
    <xsl:template match="*[local-name()='Placemark']">
        <name>{name}</name> <!-- !! -->
        <xsl:result-document method="xml" href="d:\downloads\countries\{name}.xml">-->
        <xsl:apply-templates select="*[local-name()='Polygon']"/>
        </xsl:result-document>
    </xsl:template>
    <xsl:template match="*[local-name()='Polygon']">
        <Polygon>
            <xsl:apply-templates select="*[local-name()='outerBoundaryIs']"/>
        </Polygon>
    </xsl:template>
    <xsl:template match="*[local-name()='outerBoundaryIs']">
        <outerBoundaryIs>
            <xsl:apply-templates select="*[local-name()='LinearRing']"/>
        </outerBoundaryIs>
    </xsl:template>
    <xsl:template match="*[local-name()='LinearRing']">
        <LinearRing>
                </LinearRing>
        <xsl:apply-templates select="*[local-name()='coordinates']"/>
    </xsl:template>
    <xsl:template match="*[local-name()='coordinates']">
        <coordinates>
            <xsl:value-of select="."/>
        </coordinates>
    </xsl:template>
</xsl:stylesheet>

but I can’t get the processor to recognise the ‘name’ and switch files (marked by <!-- !! -->).

Is there an XSL wizard whou could help me out?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:46:30+00:00Added an answer on May 24, 2026 at 3:46 am

    The following stylesheet works with the http://www.calvert.ch/download/world-borders.kml data (note xpath-default-namespace).

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xpath-default-namespace="http://www.opengis.net/kml/2.2"
            version="2.0">
    
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="/">
        <xsl:apply-templates select="//Folder[matches(name,'[A-Z] -')]"/>
      </xsl:template>
    
      <xsl:template match="Folder">
        <xsl:for-each select="Placemark">
          <xsl:result-document href="{name}.xml">
          <kml>
            <Document>
              <Folder>
                <name>Countries</name>
                <xsl:copy-of select="."/>
              </Folder>  
            </Document>
          </kml>
        </xsl:result-document>
        </xsl:for-each>
      </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file with: area ID area name URL of a KML
I can't get DDMS to load any KML files. I have a KML file
I have a KML file defining several paths/routes (representing actual roads) enclosed in the
I have a KML file I am calling with a NSURL every 10 seconds.
I have a rails app that creates a kml file and successfully loads it
I have a KML-file with lots of data in it. I would like to
Do you have any idea where I could find kml file with simple contours
I'm trying to build a KML file in Rails, which I have done successfully,
I have a KML file with a list of placemarks that have custom icons,
I have a kml file. I need to load this kml file into my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.