Discussion:
Need help with creating entry to match XML structure
Add Reply
Diana
2017-09-28 20:44:18 UTC
Reply
Permalink
Raw Message
Hello,

I need to create the following XML node:

<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

What I have so far is:

myEntry = system.newEntry();
myEntry.ImportData = null;
***@xmlns ="urn:Epic-com:Core.2016.Services.DataUtility";

After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried

***@xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"

And that was not the correct way.

Thanks,
Diana
Eddie Hartman
2017-09-29 18:25:11 UTC
Reply
Permalink
Raw Message
Post by Diana
Hello,
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
myEntry = system.newEntry();
myEntry.ImportData = null;
After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried
And that was not the correct way.
Thanks,
Diana
Try myEntry.ImportData["@xmlns:xsi"]="http://www.w3.org/2001/XMLSchema-instance"

When an attribute or property name includes special characters, use bracket notation.

Hope this helps!
-Eddie
Franzw
2017-10-02 13:18:58 UTC
Reply
Permalink
Raw Message
Post by Eddie Hartman
Post by Diana
Hello,
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
myEntry = system.newEntry();
myEntry.ImportData = null;
After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried
And that was not the correct way.
Thanks,
Diana
When an attribute or property name includes special characters, use bracket notation.
Hope this helps!
-Eddie
It is seldom I have the chance to Educate Eddie - but I will not let chance get lost :-)

Although Eddie's method will create the correct xml string when you convert it using Entry.toXML() it will NOT set the namespace correctly in the internal DOM tree implementation.

To do that you should use the Entry.createAttributeNS() method - eg.

myEntry.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance","ImportData");

HTH
Regards
Franz Wolfhagen
Eddie Hartman
2017-10-03 08:48:23 UTC
Reply
Permalink
Raw Message
Post by Franzw
Post by Eddie Hartman
Post by Diana
Hello,
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
myEntry = system.newEntry();
myEntry.ImportData = null;
After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried
And that was not the correct way.
Thanks,
Diana
When an attribute or property name includes special characters, use bracket notation.
Hope this helps!
-Eddie
It is seldom I have the chance to Educate Eddie - but I will not let chance get lost :-)
Although Eddie's method will create the correct xml string when you convert it using Entry.toXML() it will NOT set the namespace correctly in the internal DOM tree implementation.
To do that you should use the Entry.createAttributeNS() method - eg.
myEntry.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance","ImportData");
HTH
Regards
Franz Wolfhagen
But Franz, what difference does that make if the XML string produced is correct? My test code looks like this:
---
myEntry = system.newEntry();
myEntry.ImportData = null;
***@xmlns ="urn:Epic-com:Core.2016.Services.DataUtility";
myEntry.ImportData["@xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
myEntry.ImportData.Record="Here is the data";

task.logmsg("\n" + myEntry.toXML());
---
And the output looks like this:
---
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Record>Here is the data</Record>
</ImportData>
---
What am I missing - and yes, I'm hasty and often take turns on two wheels :)
Franzw
2017-10-03 12:16:50 UTC
Reply
Permalink
Raw Message
Post by Diana
Post by Franzw
Post by Eddie Hartman
Post by Diana
Hello,
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
myEntry = system.newEntry();
myEntry.ImportData = null;
After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried
And that was not the correct way.
Thanks,
Diana
When an attribute or property name includes special characters, use bracket notation.
Hope this helps!
-Eddie
It is seldom I have the chance to Educate Eddie - but I will not let chance get lost :-)
Although Eddie's method will create the correct xml string when you convert it using Entry.toXML() it will NOT set the namespace correctly in the internal DOM tree implementation.
To do that you should use the Entry.createAttributeNS() method - eg.
myEntry.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance","ImportData");
HTH
Regards
Franz Wolfhagen
---
myEntry = system.newEntry();
myEntry.ImportData = null;
myEntry.ImportData.Record="Here is the data";
task.logmsg("\n" + myEntry.toXML());
---
---
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Record>Here is the data</Record>
</ImportData>
---
What am I missing - and yes, I'm hasty and often take turns on two wheels :)
It makes a difference if you use a different XML JAVA framework afterwards (e.g. you call some WS that does validation with your DOM object) - then the DOM will not be namespace enabled - you will "just" have an attribute that contains a link to the namespace...

Example - doing it the simple way (which is totally okay if you just need an XML string) - and then call entry.getElementsByTagNameNS(nameSpace,tag) then you will get an error compared to defining it with createAttributeNS(nameSpace,attributeName) which will work.

It had this problem working with a very nameSpace sensitive WebService - and it took me a long time (and your help - you seem to have forgot it :-)) to find the culprit...

So this is a "feature" of TDI dot/[] nomemclature - I would not regard this as a bug....

Regards
Franz Wolfhagen
Eddie Hartman
2017-10-04 08:28:46 UTC
Reply
Permalink
Raw Message
Post by Franzw
Post by Diana
Post by Franzw
Post by Eddie Hartman
Post by Diana
Hello,
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
myEntry = system.newEntry();
myEntry.ImportData = null;
After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried
And that was not the correct way.
Thanks,
Diana
When an attribute or property name includes special characters, use bracket notation.
Hope this helps!
-Eddie
It is seldom I have the chance to Educate Eddie - but I will not let chance get lost :-)
Although Eddie's method will create the correct xml string when you convert it using Entry.toXML() it will NOT set the namespace correctly in the internal DOM tree implementation.
To do that you should use the Entry.createAttributeNS() method - eg.
myEntry.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance","ImportData");
HTH
Regards
Franz Wolfhagen
---
myEntry = system.newEntry();
myEntry.ImportData = null;
myEntry.ImportData.Record="Here is the data";
task.logmsg("\n" + myEntry.toXML());
---
---
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Record>Here is the data</Record>
</ImportData>
---
What am I missing - and yes, I'm hasty and often take turns on two wheels :)
It makes a difference if you use a different XML JAVA framework afterwards (e.g. you call some WS that does validation with your DOM object) - then the DOM will not be namespace enabled - you will "just" have an attribute that contains a link to the namespace...
Example - doing it the simple way (which is totally okay if you just need an XML string) - and then call entry.getElementsByTagNameNS(nameSpace,tag) then you will get an error compared to defining it with createAttributeNS(nameSpace,attributeName) which will work.
It had this problem working with a very nameSpace sensitive WebService - and it took me a long time (and your help - you seem to have forgot it :-)) to find the culprit...
So this is a "feature" of TDI dot/[] nomemclature - I would not regard this as a bug....
Regards
Franz Wolfhagen
Thanks for enlightening us (and me), Franz!
Diana
2017-10-13 22:20:39 UTC
Reply
Permalink
Raw Message
Thanks Eddie and Franz!

I have another question. I am trying to include the following in my soap request too:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>

I tried things like

myEntry[s:Envelope] but the resulting print out is <Envelop>. How do I get it to be <s:Envelope>.

Also, I am using InvokeSoap Web Service Function Component to send the soap request. Is there any better connector or FC to use?
Post by Diana
Hello,
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
myEntry = system.newEntry();
myEntry.ImportData = null;
After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried
And that was not the correct way.
Thanks,
Diana
Franzw
2017-10-14 20:27:45 UTC
Reply
Permalink
Raw Message
Post by Diana
Thanks Eddie and Franz!
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
I tried things like
myEntry[s:Envelope] but the resulting print out is <Envelop>. How do I get it to be <s:Envelope>.
Also, I am using InvokeSoap Web Service Function Component to send the soap request. Is there any better connector or FC to use?
Post by Diana
Hello,
<ImportData xmlns="urn:Epic-com:Core.2016.Services.DataUtility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
myEntry = system.newEntry();
myEntry.ImportData = null;
After that, I am not sure how to add the part about xmlns:xsi to myEntry. I tried
And that was not the correct way.
Thanks,
Diana
I am afraid that working with namespace is not easy - and not documented.

I will see if I can get sample composed - but the secret is to use the XML Parser (ibmdi.XML2) and the advanced parameters.

Take a look into the (Very) Advanced XML Handling here : http://www.tdi-users.org/foswiki/Integrator/HowTo on how to use the parser.

Many people will at this point stop working within the TDI methods and just write some simple text based xml handling (as Eddie described) and then rely on the http connector instead of the more advanced FCs - but that is an individual choice.

I will see if I can get the time to writ up and simple educational namespace example later this weekend that shows how to do exactly what you are looking for.

IMHO TDI is missing a couple of helper methods when working with namespace XML - but lets us show the world how to do this - I may be so lucky that I can partner with Eddie and write it up on developerworks...

HTH
Regards
Franz Wolfhagen

Loading...