column to XML node

Hi All,

I am trying to build an XML file, using the skos namespace.
I wanted to add skos under the file/preferences/xml in order to be able to use skos elements.
Unfortunately I have not yet found out how to properly add this into the knime preferences.
Is there someone who has work with this before?

Hi @matthias.albus,

I am not entirely sure if I understand correctly what you are trying to achieve. Is it writing out elements/properties from a specific namespace (skos in your case)? Also, where did you get the information about setting this in file/preferences/xml?

Best,
Stefan

Hi Stefan,

thanks much for looking into this. yes indeed I would like to create XML files, using various namespaces. Skos is one of them. I was able to build various XML files with using the “column to xml” node, as long as the name of the element and attributes do not contain a “:” as part of their name.
E.g. once I try to create an element named “skos:Concept” the “column to xml” node throws an error:

“ERROR Column To XML 0:1918 Execute failed: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 87; The prefix “skos” for element “skos:Concept” is not bound.”

So the node is parsing the XML content and to my understanding; if it would know about the skos namespace it should not give this error.
so basically I was trying to find some config in order to tell the XML nodes about this namespace.
I am also use the xpath and XML reader nodes which you configure and add namespaces.
I was mistakenly assuming under file / preferences / XML would be a general config means to add such things. I have realized now this comes with underlying eclipse.

so basically I would like to get help with my current issue, if there is a way with knime already achieving this.
perhaps it would also be worthwhile to add config option to the XML nodes allowing to configure namespaces.

best

Matthias

2 Likes

Hi @matthias.albus,

I have opened a ticket suggesting exactly this. Will keep you updated on the progress, but will say that this is not the highest of priorities at the moment.

In the meantime you could try to convert columns to JSON and use the JSON to XML node which let’s you define a namespace for elements (although not per column as far as I know).

Best,
Stefan

Hi @matthias.albus,
another a bit “hacky” solution would be to replace your colons with some other unique character sequence (e.g. “skos_._myelement”) and then do the replacement using a string manipulation node, followed by a String to XML node. Could that work?
Kind regards
Alexander

Hi @AlexanderFillbrunn and @stelfrich,

thank you both for your proposals and thanks Stefan for adding the enhancement request.
I was already using the workaround with string replacements, which indeed works but is quite ugly.
I will however also try the JSON node solution.

best

Matthias

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.