I have noticed that parseKml() function does not parse KML file correctly. For example, if you have this bit of KML:
<ExtendedData>
<Data name="Offer">
<value>Apples</value>
<value>Potatoes</value>
<value>Tomatoes</value>
</Data>
</ExtendedData>
The parseKml() function will return a kmlObject that will contain only the last value, i.e. "Tomatoes":
Does anyone have a solution for this?
The structure for the type of extended data you are using is for name/value pairs. i.e. a single name with a single value.
<ExtendedData>
<Data name="string">
<displayName>...</displayName> <!-- string -->
<value>...</value> <!-- string -->
</Data>
</ExtendedData>
So what you are trying will not work. If you wish to add an arbitrary XML Data structure to a KML Feature then you would do it like this.
<ExtendedData xmlns:offer="http://yourserver.com/namespace">
<offer:item>Apples</offer:item>
<offer:item>Potatoes</offer:item>
<offer:item>Tomatoes</offer:item>
</ExtendedData>
Based on the data structure, the 'offer' XML Schema file (http://yourserver.com/namespace) would be something like.
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="item" type="xsd:string" />
</xsd:schema>
I believe the <Data> element can only contain a single <value> - according to the docs, the "<Data> element allows you to add untyped name/value pairs to the user data associated with a given Feature."
So in your case, it's picking up the last <value> element only. You might find another way to add your custom data here: https://developers.google.com/kml/documentation/extendeddata
Related
I have two files that I want to load by using g.io(<name file>).read().iterate(): nodes.xml and edges.xml.
The nodes.xml file contains the nodes of the graph I want to upload, and its contents are this:
<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="labelV" for="node" attr.name="labelV" attr.type="string" />
<key id="name" for="node" attr.name="name" attr.type="string" />
<key id="age" for="node" attr.name="age" attr.type="int" />
<graph id="G" edgedefault="directed">
<node id="1">
<data key="labelV">person</data>
<data key="name">marko</data>
<data key="age">29</data>
</node>
<node id="2">
<data key="labelV">person</data>
<data key="name">vadas</data>
<data key="age">27</data>
</node>
</graph>
</graphml>
The edges.xml file contains the edges of the graph I want to upload, and its content are this:
<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="labelE" for="edge" attr.name="labelE" attr.type="string" />
<key id="weight" for="edge" attr.name="weight" attr.type="double" />
<graph id="G" edgedefault="directed">
<edge id="7" source="1" target="2">
<data key="labelE">knows</data>
<data key="weight">0.5</data>
</edge>
</graph>
</graphml>
I want to upload the nodes first by running g.io('nodes.xml').read().iterate() and then the edges by running g.io('edges.xml').read().iterate(). But when I upload the edges.xml, instead of adding edges to the previously created nodes, it creates new nodes.
It is possible to easily load the nodes first and then the edges in separate queries with a similar command in Gremlin? I know this can be accomplished with complex queries that involve reading and creating edge by edge the edges in the edges.xml file via user queries, but I'm wondering if there is something easier. Also, I wouldn't want to upload a single file with all the nodes and edges.
I'm afraid that the GraphMLReader doesn't work that way. It's not designed to read into an existing graph. I honestly can't remember if this was done purposefully or not.
The code isn't too complicated though. You could probably just modify it to work they way that you want. You can see here where the code checks the vertex cache for the id. That cache is empty on your second execution because it is only filled by way of new vertex additions - it doesn't remember any from your first run and it doesn't read from the graph directly for your second run. Simply change that to logic to better suit your needs.
It seems that Nosqlunit-neo4j is not compatible with SDN 4 since TypeRepresentationStrategy is removed. It adds the node defined in following graphml xml file into test database but doesn't assign it a label due to which repository.count() returns 0. However, if I query the database natively, then it does fetches the node without any Label.
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
<key id="__type__" for="node" attr.name="__type__" attr.type="string"></key>
<key id="productId" for="node" attr.name="productId" attr.type="string"></key>
<graph id="G" edgedefault="directed">
<node id="3">
<data key="__type__">com.my.package.Product</data>
<data key="productId">100001235</data>
<index name="__types__" key="className">com.my.package.Product
</index>
</node>
</graph>
</graphml>
Does anyone facing the same issue?
If you use the label Product directly it should work.
You don't need the index or the __type__ properties anymore.
I have to parse this document and I plan on using NSXMLparser but the only problem is I do not know how to get the information I want. I don't know how to navigate through each tag, I have seen simple examples but when I try to use their method I get random tags and information I don't want. Can someone explain how to get certain information from a complex XML structure such as this one?
Thanks!
<kml xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns2="http://www.w3.org/2005/Atom"
xmlns="http://www.opengis.net/kml/2.2">
<Document>
<description>Available CAR2GO Vehicles</description>
<Style id="car2go">
<IconStyle>
<Icon>
<href>http://www.car2go.com/common/images/openapi/marker_car2go.png
</href>
</Icon>
<hotSpot y="0.0" x="0.0" />
</IconStyle>
</Style>
<Style id="car2go_ed">
<IconStyle>
<Icon>
<href>http://www.car2go.com/common/images/openapi/marker_car2go_ed.png
</href>
</Icon>
<hotSpot y="0.0" x="0.0" />
</IconStyle>
</Style>
<Placemark>
<name>UL-C5887</name>
<description>Sudetenweg, 89075 Ulm<br/>Fuel
24<br/>Interior GOOD<br/>Exterior GOOD
</description>
<styleUrl>#car2go_ed</styleUrl>
<ExtendedData>
<Data name="fuel">
<value>24</value>
</Data>
<Data name="interior">
<value>GOOD</value>
</Data>
<Data name="exterior">
<value>GOOD</value>
</Data>
<Data name="vin">
<value>WME4513001K154655</value>
</Data>
<Data name="engineType">
<value>ED</value>
</Data>
<Data name="charging">
<value>true</value>
</Data>
</ExtendedData>
<Point>
<coordinates>10.029,48.4362,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>UL-C5889</name>
<description>Heilmeyersteige, 89075 Ulm<br/>Fuel
58<br/>Interior GOOD<br/>Exterior GOOD
</description>
<styleUrl>#car2go</styleUrl>
<ExtendedData>
<Data name="fuel">
<value>58</value>
</Data>
<Data name="interior">
<value>GOOD</value>
</Data>
<Data name="exterior">
<value>GOOD</value>
</Data>
<Data name="vin">
<value>WME4513001K154655</value>
</Data>
<Data name="engineType">
<value>CE</value>
</Data>
</ExtendedData>
<Point>
<coordinates>9.947235,48.410497,0</coordinates>
</Point>
</Placemark>
</Document>
I get random tags and information I don't want
With NSXMLParser you don't navigate through the XML. Instead, you create a delegate for the parser that gets messages each time the parser encounters something -- a tag, a value, etc. Your delegate needs to watch for the tags and values that it's interested in and do whatever makes sense for your app when those arrive. So, the tags you're seeing aren't random, they're just the tags from the file you're parsing in the order in which they appear in the file.
Can someone explain how to get certain information from a complex XML structure such as this one?
Generally, your parser delegate will be a little like a state machine that keeps track of which tag it's parsing, what data it sees, etc. That may be more than you're up for, in which case you might want to look into other XML parsing options than NSXMLParser. TouchXML is one library that's popular because it parses the file for you and then lets you look through the data with Xquery.
I would highly suggest you do not reinvent the wheel and use a high level 3rd party library which will make your life a ton easier. #mattt of AFNetworking fame amongst others has an excellent XML parsing library called Ono.
I suggest you examine the strategy demonstrated by Apple's own example code here:
https://developer.apple.com/library/ios/samplecode/SeismicXML/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007323
The actual parsing code is here:
https://developer.apple.com/library/ios/samplecode/SeismicXML/Listings/SeismicXML_APLParseOperation_m.html#//apple_ref/doc/uid/DTS40007323-SeismicXML_APLParseOperation_m-DontLinkElementID_11
All the work is done by the parser's delegate (which is this object, self). Notice in particular how didStartElement:... makes choices depending on what kind of element has just been encountered.
I should also mention that there is another strategy, where instead of the delegate making these choices, you keep repointing the parser at a different delegate. Here, I develop a general version of that strategy and show how to adapt it to a particular parsing situation: http://www.apeth.com/iOSBook/ch36.html#_xml
Question: I have created a sample xml document containing data conforming to the atom 1.0 schema. When I import the contents of this file (for testing purposes) in PowerPivot, it creates columns for each atom element in each entry, instead of creating a column per content element. Why is this?
Background: A customer wants to import data from a web service which provides a feed that uses a custom XML schema that is not supported by PowerPivot. The service provides the ability for the caller to supply an XSLT template that will be applied to the feed. I am hoping to be able to transform this feed into a valid atom feed thereby allowing the customer to import data into PowerPivot.
Sample atom xml:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<title type="text">My Data Feed</title>
<id>http://temp/feed</id>
<updated>2012-12-13T00:00:00Z</updated>
<entry>
<id>http://temp/feed/1</id>
<title type="text">Title</title>
<author>
<name>Author</name>
</author>
<updated>2012-12-13T00:00:00Z</updated>
<content type="application/xml">
<d:Name>John Smith</d:Name>
<d:Address>Address</d:Address>
<d:Zip>1234</d:Zip>
</content>
</entry>
</feed>
When imported into PowerPivot (selecting "From Data Feeds", clicking "Browse" and pointing out the xml file), it looks like this:
I was excpecting three columns: Name, Address and Zip. If I change "Include Atom Elements" from Auto to False in the connection configuration, no columns are imported.
It seems I was just missing the m:properties element. Final result - also includes examples of null attributes and data types:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<title type="text">My Data Feed</title>
<id>http://temp/feed</id>
<updated>2012-12-13T00:00:00Z</updated>
<entry>
<id>http://temp/feed/1</id>
<title type="text">Title</title>
<author>
<name>Author</name>
</author>
<updated>2012-12-13T00:00:00Z</updated>
<content type="application/xml">
<!-- attributes placed under the properties element -->
<m:properties>
<d:Name>John Smith</d:Name>
<d:Address>Address</d:Address>
<d:Zip m:type="Edm.Int32">1234</d:Zip>
<d:Comment m:null="true" />
</m:properties>
</content>
</entry>
</feed>
I have the below xml's in my code
XML Parsing Error: not well-formed
Location: http://localhost:3000/api/client?client=test1
Line Number 1, Column 1111:
<?xml version="1.0" encoding="UTF-8"?>
<application>
<name><![CDATA[TESTapp2]]></name>
<application-identifier>wac-8c28afa4-0f6e-11e1-8885-7071bc62c7bc</application-identifier>
<clients>
<pricepoint id="1" name=<![CDATA[TEST-price]]> currency="dollar" locale="la" country="india" price="50" text="this is a TEST" receipt="oi120934" operator-reference="1213w" operator-id="1"></pricepoint></pricepoints><product-image></product-image>
</clients>
</application>
<name><![CDATA[TESTapp2]]></name> this is working
<name=\"[CDATA[TESTapp2]]\"> this is not working,throws encoding error
AFAIK, Using CDATA as an attribute value is forbidden. CDATA can only be used for text nodes.