Newbies ozbigben Posted January 26, 2013 Newbies Posted January 26, 2013 Hi All Trying a relatively simple import of two text fields from some kml data but there's a mistake I'm not picking up. While I don't get any errors, I also don't get any records created. Any help would be appreciated. XSLT: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/> <xsl:template match="/"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <ERRORCODE>0</ERRORCODE> <PRODUCT BUILD="" NAME="" VERSION=""/> <DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/> <METADATA> <FIELD NAME="POSTCODE" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="SHAPE" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> </METADATA> <RESULTSET FOUND=""> <xsl:for-each select="Document/Folder/Placemark"> <ROW MODID="" RECORDID=""> <COL><DATA><xsl:value-of select="name"/></DATA></COL> <COL><DATA><xsl:value-of select="Polygon/outerBoundaryIs/LinearRing/coordinates"/></DATA></COL> </ROW> </xsl:for-each> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet> XML sample: <?xml version="1.0" encoding="iso-8859-1"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"> <Document> <!-- Begin Style Definitions --> <Style id="area1"> <LineStyle> <color>FF808080</color> <width>2</width> </LineStyle> <PolyStyle> <color>BF000000</color> <fill>0</fill> <outline>1</outline> </PolyStyle> </Style> <Folder> <name>Area Features</name> <description>Area Features</description> <Placemark> <description>County Subdivision</description> <name>0800</name> <styleUrl>#area1</styleUrl> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates> 130.8339472320,-12.4574101091,0 130.8345397120,-12.4579840531,0 130.8352064320,-12.4586632806,0 </coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> <Placemark> <description>County Subdivision</description> <name>0810</name> <styleUrl>#area1</styleUrl> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates> 130.8458432320,-12.4026033781,0 130.8523644480,-12.4025805491,0 130.8523654720,-12.4026570836,0 </coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Folder> </Document> </kml>
comment Posted January 26, 2013 Posted January 26, 2013 I see two problems with your stylesheet: First, the root element of your XML source is <kml> so the reference to "Document/Folder/Placemark" doesn't find anything. The other issue is that the root element (and consequently all of its children) lives in its own namespace, so you must define a prefix for this namespace and use it when calling any element - something like: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:k="http://www.opengis.net/kml/2.2" exclude-result-prefixes="k"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:template match="/"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <ERRORCODE>0</ERRORCODE> <PRODUCT BUILD="" NAME="" VERSION=""/> <DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/> <METADATA> <FIELD NAME="POSTCODE" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="SHAPE" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> </METADATA> <RESULTSET FOUND=""> <xsl:for-each select="k:kml/k:Document/k:Folder/k:Placemark"> <ROW MODID="" RECORDID=""> <COL><DATA><xsl:value-of select="k:name"/></DATA></COL> <COL><DATA><xsl:value-of select="k:Polygon/k:outerBoundaryIs/k:LinearRing/k:coordinates"/></DATA></COL> </ROW> </xsl:for-each> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet>
Newbies ozbigben Posted January 26, 2013 Author Newbies Posted January 26, 2013 Thanks for that. I now have a nice set of data for visualising survey response stats in Google maps and a good idea of which XML tutorials I need to do next
Recommended Posts
This topic is 4585 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now