There is a plugin that forms an XML file for exporting goods. But no matter how hard I try, I can not insert the code <?xml version = "1.0" encoding = "utf-8"?> at the beginning of the line. Unfortunately, it is necessary for the validation of the file. Now produces this way:
<root>
<object>
<objectid></objectid>
<title></title>
<type></type>
...
</object>
<object>...</object>
...
</root>
I'm not a pro on this issue, but I will give only a piece of code in which the problem is possible:
public function onAjaxBTExport()
{
$xml = new SimpleXMLElementExtended('<root/>');
....
$data = $xml->asXML();
file_put_contents(JPATH_SITE.'/data.xml', $data);
header('Content-type: text/xml');
echo $data;
die;
}
class SimpleXMLElementExtended extends SimpleXMLElement
{
private function addCDataToNode(SimpleXMLElement $node, $value = '')
{
if ($domElement = dom_import_simplexml($node))
{
$domOwner = $domElement->ownerDocument;
$domElement->appendChild($domOwner->createCDATASection("{$value}"));
}
}
public function addChildWithCData($name = '', $value = '')
{
$newChild = parent::addChild($name);
if ($value) $this->addCDataToNode($newChild, "{$value}");
return $newChild;
}
public function addCData($value = '')
{
$this->addCDataToNode($this, "{$value}");
}
}
Consider running XSLT (the XML transformation language) using the identity tranform template which copies entire document as is and then explicitly set the omit-xml-declaration to "no". The added benefit of this is pretty printing your output.
To run XSLT 1.0 in PHP, be sure to enable the php-xsl extension in .ini file. Below XSLT is embedded as string but can be parsed from file.
$xml = new SimpleXMLElementExtended('<root/>');
...
$data = $xml->asXML();
// LOAD XML SOURCE
$doc = new DOMDocument;
$doc->loadXML($data);
// LOAD XSLT SOURCE
$xsl = new DOMDocument;
$xsl->loadXML('<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="yes" />
<xsl:strip-space elements="*"/>
<!-- Identity Transform -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:transform>');
// CONFIGURE TRANSFORMER
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
// RUN TRANSFORMATION
$newXML = $proc->transformToXML($doc);
// ECHO TO CONSOLE
header('Content-type: text/xml');
echo $newXML;
// SAVE TO FILE
file_put_contents(JPATH_SITE.'/data.xml', $newXML);
Related
I am parsing an XML file (source.xml) in PHP and need to identify instances where the <property> node contains the <rent> element.
Once identified the entire <property> parent node for that entry should be copied to a separate XML file (destination.xml).
On completion of the copy that <property> node should be removed from the source.xml file.
Here is an example of the source.xml file:
<?xml version="1.0" encoding="utf-8"?>
<root>
<property>
...
<rent>
<term>long</term>
<freq>month</freq>
<price_peak>1234</price_peak>
<price_high>1234</price_high>
<price_medium>1234</price_medium>
<price_low>1234</price_low>
</rent>
...
</property>
</root>
I've tried using DOM with the below code however I'm not getting any results at all despite their being hundreds of nodes that match the above requisites. Here is what I have so far:
$destination = new DOMDocument;
$destination->preserveWhiteSpace = true;
$destination->load('destination.xml');
$source = new DOMDocument;
$source->load('source.xml');
$xp = new DOMXPath($source);
foreach ($xp->query('/root/property/rent[term/freq/price_peak/price_high/price_medium/price_low]') as $item) {
$newItem = $destination->documentElement->appendChild(
$destination->createElement('property')
);
foreach (array('term', 'freq', 'price_peak', 'price_high', 'price_medium', 'price_low') as $elementName) {
$newItem->appendChild(
$destination->importNode(
$item->getElementsByTagName($elementName)->property(0),
true
)
);
}
}
$destination->formatOutput = true;
echo $destination->saveXml();
I've only started learning about DOMDocument and it's uses so I'm obviously messing up somewhere so any help is appreciated. Many thanks.
The difficulty is when your trying to copy a node from one document to another. You can try and re-create the node, copying all of the components across, but this is hard work (and prone to errors). Instead you can import the node from one document to another using importNode. The second parameter says copy all child elements as well.
Then deleting the element from the original document is a case of getting the item to 'delete itself from it's parent' which sounds odd, but thats how this code works.
<?php
error_reporting ( E_ALL );
ini_set ( 'display_errors', 1 );
$destination = new DOMDocument;
$destination->preserveWhiteSpace = true;
$destination->loadXML('<?xml version="1.0" encoding="utf-8"?><root></root>');
$source = new DOMDocument;
$source->load('NewFile.xml');
$xp = new DOMXPath($source);
$destRoot = $destination->getElementsByTagName("root")->item(0);
foreach ($xp->query('/root/property[rent]') as $item) {
$newItem = $destination->importNode($item, true);
$destRoot->appendChild($newItem);
$item->parentNode->removeChild($item);
}
echo "Source:".$source->saveXML();
$destination->formatOutput = true;
echo "destination:".$destination->saveXml();
With the destination, I prime it with the basic <root> element and then add in the contents from there.
Did you wanted to obtain something like this? Hope this helps:
$inXmlFile = getcwd() . "/source.xml";
$inXmlString = file_get_contents($inXmlFile);
$outXmlFile = getcwd() . "/destination.xml";
$outXmlString = file_get_contents($outXmlFile);
$sourceDOMDocument = new DOMDocument;
$sourceDOMDocument->loadXML($inXmlString);
$sourceRoot = null;
foreach ($sourceDOMDocument->childNodes as $childNode) {
if(strcmp($childNode->nodeName, "root") == 0) {
$sourceRoot = $childNode;
break;
}
}
$destDOMDocument = new DOMDocument;
$destDOMDocument->loadXML($outXmlString);
$destRoot = null;
foreach ($destDOMDocument->childNodes as $childNode) {
if(strcmp($childNode->nodeName, "root") == 0) {
$destRoot = $childNode;
break;
}
}
$xmlStructure = simplexml_load_string($inXmlString);
$domProperty = dom_import_simplexml($xmlStructure->property);
$rents = $domProperty->getElementsByTagName('rent');
if(($rents != null) && (count($rents) > 0)) {
$destRoot->appendChild($destDOMDocument->importNode($domProperty->cloneNode(true), true));
$destDOMDocument->save($outXmlFile);
$sourceRoot->removeChild($sourceRoot->getElementsByTagName('property')->item(0));
$sourceDOMDocument->save($inXmlFile);
}
Consider running two XSLT transformations: one that adds <property><rent> nodes in destination and one that removes these nodes from source. As background, XSLT is a special-purpose language designed to transform XML files even maintaining a document() function to parse from external XML files in same folder or subfolder.
PHP can run XSLT 1.0 scripts with its php-xsl class (be sure to enable extension in .ini file). With this approach no if logic or foreach loops are needed.
XSLT Scripts
PropertyRentAdd.xsl (be sure source.xml and XSLT are in same folder)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- IDENTITY TRANSFORM -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<!-- ADD TEMPLATE -->
<xsl:template match="root">
<xsl:copy>
<xsl:copy-of select="*"/>
<xsl:copy-of select="document('source.xml')/root/property[local-name(*)='rent']"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
PropertyRentRemove.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- IDENTITY TRANSFORM -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<!-- REMOVE TEMPLATE -->
<xsl:template match="property[local-name(*)='rent']">
</xsl:template>
</xsl:stylesheet>
PHP
// Set current path
$cd = dirname(__FILE__);
// Load the XML and XSLT files
$doc = new DOMDocument();
$doc->load($cd.'/destination.xml');
$xsl = new DOMDocument;
$xsl->load($cd.'/PropertRentAdd.xsl');
// Transform the destination xml
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
$newXml = $proc->transformToXML($xml);
// Save output to file, overwriting original
file_put_contents($cd.'/destination.xml', $newXml);
// Load the XML and XSLT files
$doc = new DOMDocument();
$doc->load($cd.'/source.xml');
$xsl = new DOMDocument;
$xsl->load($cd.'/PropertRentRemove.xsl');
// Transform the source xml
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
$newXml = $proc->transformToXML($xml);
// Save output overwriting original file
file_put_contents($cd.'/source.xml', $newXml);
Inputs (examples to demonstrate, with other tags to show content is not affected)
source.xml
<?xml version="1.0" encoding="utf-8"?>
<root>
<property>
<rent>
<term>long</term>
<freq>month</freq>
<price_peak>1234</price_peak>
<price_high>1234</price_high>
<price_medium>1234</price_medium>
<price_low>1234</price_low>
</rent>
</property>
<property>
<rent>
<term>short</term>
<freq>month</freq>
<price_peak>7890</price_peak>
<price_high>7890</price_high>
<price_medium>7890</price_medium>
<price_low>7890</price_low>
</rent>
</property>
<property>
<web_site>stackoverflow</web_site>
<general_purpose>php</general_purpose>
</property>
<property>
<web_site>stackoverflow</web_site>
<special_purpose>xsl</special_purpose>
</property>
</root>
destination.xml
<?xml version="1.0" encoding="utf-8"?>
<root>
<original_data>
<test1>ABC</test1>
<test2>123</test2>
</original_data>
<original_data>
<test1>XYZ</test1>
<test2>789</test2>
</original_data>
</root>
Output (after PHP run)
source.xml
<?xml version="1.0"?>
<root>
<property>
<web_site>stackoverflow</web_site>
<general_purpose>php</general_purpose>
</property>
<property>
<web_site>stackoverflow</web_site>
<special_purpose>xsl</special_purpose>
</property>
</root>
destination.xml (new nodes appended at bottom)
<?xml version="1.0"?>
<root>
<original_data>
<test1>ABC</test1>
<test2>123</test2>
</original_data>
<original_data>
<test1>XYZ</test1>
<test2>789</test2>
</original_data>
<property>
<rent>
<term>long</term>
<freq>month</freq>
<price_peak>1234</price_peak>
<price_high>1234</price_high>
<price_medium>1234</price_medium>
<price_low>1234</price_low>
</rent>
</property>
<property>
<rent>
<term>short</term>
<freq>month</freq>
<price_peak>7890</price_peak>
<price_high>7890</price_high>
<price_medium>7890</price_medium>
<price_low>7890</price_low>
</rent>
</property>
</root>
I have a problem... I want to rename the tags in some XML files. An it works with this code:
$xml = file_get_contents('data/onlinekeystore.xml');
renameTags($xml, 'priceEUR', 'price', 'data/onlinekeystore.xml');
But if I want to rename another XML file it doens't work with the SAME method...
See the example below. I have no idea why...
Does anybody has an idea and can help me?
$xml = file_get_contents('data/g2a.xml');
renameTags($xml, 'name', 'title', 'data/g2a.xml');
Function Code:
function renameTags($xml, $old, $new, $path){
$dom = new DOMDocument();
$dom->loadXML($xml);
$nodes = $dom->getElementsByTagName($old);
$toRemove = array();
foreach ($nodes as $node) {
$newNode = $dom->createElement($new);
foreach ($node->attributes as $attribute) {
$newNode->setAttribute($attribute->name, $attribute->value);
}
foreach ($node->childNodes as $child) {
$newNode->appendChild($node->removeChild($child));
}
$node->parentNode->appendChild($newNode);
$toRemove[] = $node;
}
foreach ($toRemove as $node) {
$node->parentNode->removeChild($node);
}
$dom->saveXML();
$dom->save($path);
}
onlinekeystore.xml Input:
<product>
<priceEUR>5.95</priceEUR>
</product>
onlinekeystore.xml Ouput:
<product>
<price>5.95</price>
</product>
g2a.xml Input:
<products>
<name><![CDATA[1 Random STEAM PREMIUM CD-KEY]]></name>
</products>
g2a.xml Ouput:
<products>
<name><![CDATA[1 Random STEAM PREMIUM CD-KEY]]></name>
</products>
Greetings
Consider a dynamic XSLT running the Identity Transform and then updates node names in a specific template anywhere in document. The sprintf formats XSL string passing in $old and $new values. This process avoids any nested looping through entire tree and even pretty prints output no matter the format of input.
function renameTags($xml, $old, $new, $path){
// LOAD XML
$dom = new DOMDocument();
$dom->loadXML($xml);
// LOAD XSL
$xslstr = '<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output version="1.0" encoding="UTF-8" indent="yes" method="xml" cdata-section-elements="%2$s"/>
<xsl:strip-space elements="*"/>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="%1$s">
<xsl:element name="%2$s">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:transform>';
$xsl = new DOMDocument();
$xsl->loadXML(sprintf($xslstr, $old, $new));
// INITIALIZE TRANSFORMER (REQUIRES php_xsl EXTENSION ENABLED IN .ini)
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
// TRANSFORM XML AND SAVE OUTPUT
$newXML = $proc->transformToXML($dom);
file_put_contents($path, $newXML);
}
Output
renameTags('<product><priceEUR>5.95</priceEUR></product>', 'priceEUR', 'price', 'data/onlinekeystore.xml');
// <?xml version="1.0" encoding="UTF-8"?>
// <product>
// <price><![CDATA[5.95]]></price>
// </product>
renameTags('<products><name><![CDATA[1 Random STEAM PREMIUM CD-KEY]]></name></products>', 'name', 'title', 'data/g2a.xml');
// <?xml version="1.0" encoding="UTF-8"?>
// <products>
// <title><![CDATA[1 Random STEAM PREMIUM CD-KEY]]></title>
// </products>
Note: In XSLT, the <![CDATA[...]] tags are not preserved unless explicitly specified in <xsl:output>. Right now, any new node's text is wrapped with it. Remove the output spec and no CData tags render. So either include such escape tags for all or none.
Hi I have a xml file and i'm transforming it's values from xsl file in php. I want to display the new values as an xml. I can get values echoed in the php but when I put the header it gives an error saying junk after element. and I cannot use saveXML() to the returned string.
I need to save these returned information in a new xml file which I have no idea how to do. Please help me in this> thank you in advance.
php file
<?php
//header('Content-Type: text/xml');
$xmlDoc = new DOMDocument('1.0');
$xmlDoc->formatOutput = true;
$xmlDoc->load("rental.xml");
$xslDoc = new DomDocument('1.0');
$xslDoc->load("apartment.xsl");
$proc = new XSLTProcessor;
$proc->importStyleSheet($xslDoc);
$strXml= $proc->transformToXML($xmlDoc);
//echo (toXml($strXml));
echo ($strXml);
//echo $strXml->saveXML();
?>
xsl file
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:for-each select="//property">
<xsl:element name="rentalProperties">
<xsl:element name="description">
<xsl:value-of select="description"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This code will help u to save xml string to a file.
<?php
//header('Content-Type: text/xml');
$xmlDoc = new DOMDocument('1.0');
$xmlDoc->formatOutput = true;
$xmlDoc->load("rental.xml");
$xslDoc = new DomDocument('1.0');
$xslDoc->load("apartment.xsl");
$proc = new XSLTProcessor;
$proc->importStyleSheet($xslDoc);
$strXml= $proc->transformToXML($xmlDoc);
//echo (toXml($strXml));
echo ($proc->transformToXML($xmlDoc));
//$strXml->saveXML();
// Way to parse XML string and save to a file
$convertedXML = simplexml_load_string($strXml);
$convertedXML->saveXML("member.xml");
?>
Cheers.
I am trying to include different source files (e.g. file1.xml and file2.xml) and have these includes resolved for an XSLT transformation using PHPs XSLTProcessor. This is my input:
source.xml
<?xml version="1.0" encoding="utf-8" ?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file1.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file2.xml" />
</root>
transform.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude">
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()" />
</xsl:copy>
</xsl:template>
</xsl:transform>
transform.php
<?php
function transform($xml, $xsl) {
global $debug;
// XSLT Stylesheet laden
$xslDom = new DOMDocument("1.0", "utf-8");
$xslDom->load($xsl, LIBXML_XINCLUDE);
// XML laden
$xmlDom = new DOMDocument("1.0", "utf-8");
$xmlDom->loadHTML($xml); // loadHTML to handle possibly defective markup
$xsl = new XsltProcessor(); // create XSLT processor
$xsl->importStylesheet($xslDom); // load stylesheet
return $xsl->transformToXML($xmlDom); // transformation returns XML
}
exit(transform("source.xml", "transform.xsl"));
?>
My desired output is
<?xml version="1.0" encoding="utf-8" ?>
<root>
<!-- transformed contents of file1.xml -->
<!-- transformed contents of file2.xml -->
</root>
My current output is an exact copy of my source file:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file1.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file2.xml" />
</root>
It turned out, I just forgot one simple but important line in my PHP code. I had to call DOMDocument::xinclude to have the includes resolved before the transformation is done.
The full example:
<?php
function transform($xml, $xsl) {
global $debug;
// XSLT Stylesheet laden
$xslDom = new DOMDocument("1.0", "utf-8");
$xslDom->load($xsl, LIBXML_XINCLUDE);
// XML laden
$xmlDom = new DOMDocument("1.0", "utf-8");
$xmlDom->load($xml);
$xmlDom->xinclude(); // IMPORTANT!
$xsl = new XsltProcessor();
$xsl->importStylesheet($xslDom);
return $xsl->transformToXML($xmlDom);
}
exit(transform("source.xml", "transform.xsl"));
?>
I have a PHP script that caches a remote XML file. I want to XSL transform it before caching, but don't know how to do this:
<?php
// Set this to your link Id
$linkId = "0oiy8Plr697u3puyJy9VTUWfPrCEvEgJR";
// Set this to a directory that has write permissions
// for this script
$cacheDir = "temp/";
$cachetime = 15 * 60; // 15 minutes
// Do not change anything below this line
// unless you are absolutely sure
$feedUrl="http://mydomain.com/messageService/guestlinkservlet?glId=";
$cachefile = $cacheDir .$linkId.".xml";
header('Content-type: text/xml');
// Send from the cache if $cachetime is not exceeded
if (file_exists($cachefile) && (time() - $cachetime
< filemtime($cachefile)))
{
include($cachefile);
echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." -->\n";
exit;
}
$contents = file_get_contents($feedUrl . $linkId);
// show the contents of the XML file
echo $contents;
// write it to the cache
$fp = fopen($cachefile, 'w');
fwrite($fp, $contents);
fclose($fp);
?>
This is the XSL string I want to use to transform it:
<xsl:template match="/">
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<xsl:apply-templates select="messageList" />
</Document>
</kml>
</xsl:template>
<xsl:template match="messageList">
<name>My Generated KML</name>
<xsl:apply-templates select="message" />
</xsl:template>
<xsl:template match="message">
<Placemark>
<name><xsl:value-of select="esnName" /></name>
<Point>
<coordinates>
<xsl:value-of select="latitude" />,<xsl:value-of select="longitude" />
</coordinates>
</Point>
</Placemark>
</xsl:template>
I want to actually transform XML input and save/return a KML format. Can someone please help adjust this script? This was given to me and I am a little new to it.
$domOrigin = new DOMDocument('1.0');
$domOrigin->loadXML($contents);
$domXsl = new DOMDocument('1.0');
$domXsl->load('/path/to/stylesheet.xsl',LIBXML_NOCDATA);
$processor = new XSLTProcessor();
$processor->importStylesheet($domXsl);
file_put_contents($cachfile, $processor->transformToXml($domOrigin));
Ill leave it to you to integrate that :-)
Use the XSL extension, there is an example here:
http://www.php.net/manual/en/book.xsl.php#90510
replace your file_get_contents call with:
$XML = new DOMDocument();
$XML->load( $feedUrl . $linkId );
/*
this is the same as the example:
*/
$xslt = new XSLTProcessor();
$XSL = new DOMDocument();
$XSL->load( $xslFile );
$xslt->importStylesheet( $XSL );
then replace the "print" line with file_put_contents( $cachefile, $xslt->transformToXML( $XML ) );
Never use include on anything except a local php source file. It will process the included contents as PHP source. Here is readfile() for other content.
ext/xslt provides an XSLT 1.0 processor with EXSLT support.
I suggest using the cache file as a fallback if here is an error fetch or transforming the external resource also.
$contents = '';
// validate cache
if (
(!$useCache) ||
(!file_exists($chacheFile)) ||
(filemtime($cacheFile) > time() - $expires)
) {
// fetch and transform xml content
$contents = fetchAndTransform($xmlFile, $xsltFile);
if ($useCache) {
// write cache file
file_put_contents($cacheFile, $contents);
}
}
// invalid cache or fetch/transform failure - read cache file
if ($useCache && !$contents) {
// read cache file
$contents = file_get_contents($cacheFile);
}
// output if here is contents
if ($contents) {
} else {
// error handling
}
function fetchAndTransform(string $xmlFile, string $xsltFile): string {
// read xml into DOM
$xmlDocument = new DOMDocument();
$xmlDocument->load($xmlFile);
// read xsl into DOM
$xslDocument = new DOMDocument();
$xslDocument->load($xsltFile);
// initialize xslt processor
$processor = new XSLTProcessor();
// import template
$processor->importStylesheet($xslDocument);
// transform
return $processor->transformToXml($xmlDocument);
}
The namespaces are applied to the nodes while parsing the XSLT (during $xslDocument->load($xsltFile). You need to define the KML namespace (http://www.opengis.net/kml/2.2) on the XSL stylesheet element. So that the parser will put any element without a namespace prefix into it. Otherwise Placemark, name, ... will not be in the KML namespace.
<?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/kml/2.2">
<xsl:template match="/">
<kml>
<Document>
<xsl:apply-templates select="messageList" />
</Document>
</kml>
</xsl:template>
<xsl:template match="messageList">
<name>My Generated KML</name>
<xsl:apply-templates select="message" />
</xsl:template>
<xsl:template match="message">
<Placemark>
<name><xsl:value-of select="esnName" /></name>
<Point>
<coordinates>
<xsl:value-of select="latitude" />,<xsl:value-of select="longitude" />
</coordinates>
</Point>
</Placemark>
</xsl:template>
</xsl:stylesheet>
XSLT;