I'd like to create XML file from Excel sheet. But in my XML file there is multiple placement of same element, but always with different atributes (like element variable and atribute is that variable name).
<?xml version="1.0" encoding="utf-8"?>
<Configuration typical="Configurator1">
<TypicalInstance name="Typical1">
<Instance>
<ConfigurationVariables>
<ConfigurationVariable name="typical1Variable1">T1Value1</ConfigurationVariable>
<ConfigurationVariable name="typical1Variable2">T1Value2</ConfigurationVariable>
</ConfigurationVariables>
</Instance>
<Instance>
<ConfigurationVariables>
<ConfigurationVariable name="typical1Variable1">T1Value11</ConfigurationVariable>
<ConfigurationVariable name="typical1Variable2">T1Value12</ConfigurationVariable>
</ConfigurationVariables>
</Instance>
</TypicalInstance>
</Configuration>
So I have two properties named typical1Variable1 and 2. So I need two separated columns for filling data in. Each row should be done like another Instance element.
Is this even possible with native XML mapping?
Thanks for answers.
Related
I have some troubles with an Excel-file when opening it:
Entfernter Teil: Teil /xl/drawings/drawing1.xml. (Zeichnungsform)
Entferntes Feature: Objekt von /xl/printerSettings/printerSettings1.bin-Part (Datenspeicher)
When I click yes to see the file I'm missing all the data I entered with a check box and Exel opens the file with a repair-modus. An older version of the Excel has the data.
I'm wonder where I can find the data if I open the xlsx-container with zip. I suppose it should be an xml-file but couldn't find it. I have only one sheet.
Update (1)
I found where the data are: sharedStrings.xml.
But the results from check boxes are not in this xml-File. The check box info are in directory ctrlProps (for example ctrlProp1.xml) but there are no links between content of ctrlProp1.xml and sharedStrings.xml.
ctrlProp1.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<formControlPr xmlns="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" objectType="CheckBox" lockText="1" noThreeD="1"/>
I know Spring Integration is rather old but I have a piece of code that needs small modification to move on. I need to split the incoming XML message and preserve the parent node. Here is my XML:
<Order>
<Item>A</Item>
<Item>B</Item>
</Order>
And I want to split into 2 XMLs and preserve the XSD validation.
<Order>
<Item>A</Item>
</Order>
and
<Order>
<Item>B</Item>
</Order>
Did this:
<beans xmlns:int-xml="http://www.springframework.org/schema/integration/xml">
...
<int-xml:xpath-splitter id="splitter">
<int-xml:xpath-expression expression="/Order/Item"/>
</int-xml:xpath-splitter>
...
It split into
<Item>A</Item>
and
<Item>B</Item>
but I need the parent to be there. Anyway to make it works? Thanks in Advance.
What you need is an <int-xml:xslt-transformer> after your <int-xml:xpath-splitter>.
See Reference Manual for more info: https://docs.spring.io/spring-integration/docs/5.2.0.RELEASE/reference/html/xml.html#xml-xslt-payload-transformers
You need to learn what is XSLT and so on.
I know Spring Integration is rather old
??
It is actively maintained and enhanced; there was a completely new release this month.
You either need a custom splitter, or you can add a transformer after the splitter to add the outer node.
I'm trying to make a section of my SOAP request look like this:
<![CDATA[<?xml version="1.0" encoding="UTF-8"?><placeholder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="WirelessEdgeInfo_v1_0.xsd"/>]]>
However, it looks like this after it has been escaped by underlying JAXB:
<![CDATA[<?xml version="1.0"
encoding="UTF-8"?> <placeholder
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="WirelessEdgeInfo_v1_0.xsd"/>]]>
I have looked at numerous examples, such as using MOXy and also implementing a CharacterEscapeHandler adapter or XmlAdapter HOWEVER the problem is the same for ALL these implementations. That is, it always comes down to this:
marshaller.setProperty(CharacterEscapeHandler.class.getName(),
new XmlCharacterHandler());
Setting a property in the marshaller.
However, in my case, I am using annotations generated through WSImport to generate my Web Services code dynamically when I execute the client SOAP call.
i.e. I do not have access to the marshaller object.
SO for me, how can I unescape the CDATA section of a String variable I need to pass in if I cannot set any property on the marshaller type?
Can I somehow "hack" or trick JAXB to tell it not to escape CDATA values? Or can I use annotations or somehow dynamically indicate unescaping?
I tried the following Adapter via annotation but of course this did not work:
#XmlJavaTypeAdapter(value=CDATAAdapter.class) //this is not working right now
protected String variableXmlContent;
variableXmlContent still ended up escaped. I also tried unescaping variableXmlContent and setting it as an input value, but it still came out the same way, unescaped.
An XML element value containing <, >, & is escaped by the marshaller using <, >, &.
Thus, if the XML element should contain
<![CDATA[ ... ]]>
the result in the XML file will be
<![CDATA[ ... ]]>
I suspect that the text to be passed as an XML element is
<?xml version="1.0" ... v1_0.xsd"/>
Now if I had to write this by hand into an XML file, I'd write it into a "CDATA section", but a (JAXB) marshaller will simply treat those three characters as I described before, and that's it.
<?xml version="1.0" ... v1_0.xsd"/>
It is pointless to try and make any XML marshaller use the CDATA mechanism, and there is no such thing as a "CDATA value" requiring special treatment - so there is no such special treatment.
I have developed the following network link for dynamic updates :
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink>
<name>Loads TEST.kml</name>
<Link>
<href>/home/desktop/farhan/test.kml</href>
</Link>
</NetworkLink>
</kml>
Test.kml file has two placemarks.
My network link file is getting successfully updated on changes in Test.kml file
Now what I want to do is to place an 'IF' condition so that if a certain thing is true then placemark color is 'Green' Else 'Red'.
What should I do here ?? Is there any Java API I need to follow.
Depends how/where you want to host the KML and what those conditions are.
If the styles and conditions are static then you can generate the KML pre-set with those styles as part of the KML. For example, if you want to generate the KML based on some conditions such as population size > 100K => red, size > 50K => blue, otherwise white where each generated Placemark would have the appropriate shared share or inline style.
One popular Java-API to generate KML is the Java API for KML (or JAK for short).
If the views (based on conditions) are "dynamic" and user-selected then you have a couple of options:
Generate different versions/views of the Placemarks based on different conditions with NetworkLinks and radioFolders to load a particular view. The KML could be statically generated once or dynamically via a web-service, servlet, CGI-script, etc.
For example, the USGS has an earthquake real-time feed with multiple NetworkLinks each with a different view/color/size scheme for the same data (e.g. color by age vs magnitude).
Check out http://earthquake.usgs.gov/earthquakes/feed/earthquakes.kml
Use the Google Earth API to load, create, and modify KML in context of HTML and JavaScript with Google Earth running as a plugin in your web browser. This requires some JavaScript programming.
Use NetworkLinks as shown in your example combined with NetworkLinkControl elements to globally change the shared styles. See NetworkLinkControl tutorial. You can't add NetworkLinkControl elements to your KML directly in Google Earth so you have to author your KML manually or programmatically.
use php , if you are aware of it and generate kml with the help of your table and also you can use various plugins and JAK as told by jason above.
What you can do is :
connect your mysql db ( having latnlong ) through jdbc.
2 .Run a loop i.e while loop which will add placemarks as per the latitude and longitude and add other necessary element of kml like :
Element ristyle = doc.createElement("IconStyle"); // this will create an Icon.
make a new file through :
Result dest = new StreamResult(new File("file location"));
this will create your new kml file
-- place a condition here which will show your condition like a normal loop.
5 Make a network link and refer your kml file in this for manual updation.
I think this should work
Sorry in advance if this is a noob question.
All kml files start with roughly the same two lines:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
In the second line there is a reference to a web address which contains the schema for kml.
Am i to understand that this is contacted every time a kml file is
read ?
Secondly, is it possible (and how) to not have to contact
this (and other) addresses ?
The xmlns reference in a KML file only defines the XML namespace which happens to be associated with an XML Schema that defines that namespace.
Google Earth or Google Maps do NOT download the KML schema every time a KML file is accessed. In fact, it won't ever download the XML schema. The namespace just tells GE how to handle the file.
It just so happens that the Namespace URI for KML is a URL that redirects to the appropriate XML Schema.
In fact the complete schema reference for KML would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/kml/2.2
http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd">
...
</kml>
A description of XML namespaces can be found here:
http://www.w3.org/TR/REC-xml-names/#sec-namespaces
On a related note the standard icons you can use for your KML placemarks (e.g. http://maps.google.com/mapfiles/kml/shapes/airports.png) are likewise never downloaded by the Google Earth client. Those images are part of the installed Google Earth application from which Google Earth maps URLs to the local image file.