Is there a trick to assigning a value to an attribute of an element in an XML variable using XPATH inside a setValue activity? When I try something like
Location
/process_var/xml_var/test/@ID
Expression:
/process_var/test_value
it complains about the @ sign in the location assignment. I seem to be able to retrieve attributes just fine.
Views
Replies
Total Likes
Hi,
Did you try following?
Location
/process_var/xml_var/test[@ID]
regards,
Parth
Views
Replies
Total Likes
Yup. Tried all manner of variants. Tried messing with the XSD. Tried not using an XSD. Bottom line, I don't seem to be able to set ONLY the attribute of an element.
Views
Replies
Total Likes
Just tried it here and it worked fine using your original syntax:
I do find it strange that you woudl have an ID attribute off of the root node test. Is that your structure? You must path from the root to the appropriate node:
/process_var/xml_var/test/node1/node2/@ID
where ID is an attribute of node2.
If that does not work post your XML and I will give it a try here.
Paul
Views
Replies
Total Likes
Still having this issue.
If I have an XML process variable which currently contains
<Document>
<Title />
<Author />
<Date />
</Document>
Try this, it fails.
Location: /process_data/xml/Document/@ID
Expression: 54
Try this, it works.
Location: /process_data/xml/Document/ID
Expression: 54
<Document ID="">
<Title />
<Author />
<Date />
</Document>
Try this, it works, where it failed earlier.
Location: /process_data/xml/Document/@ID
Expression: 54
It appears to me, you can ADD a new node, but you can't ADD an attribute
Views
Replies
Total Likes
Some more testing.
If I have an XML process variable which currently contains
<Document>
<Title />
<Author />
<Date />
</Document>
Create a process variable, small_xml, which looks like <Date ID="27822"/>
Try this, it doesn't throw an error, but it doesn't set the value.
Location: /process_data/xml/Document/Date
Expression: /process_data/small_xml/Date
Create a process variable, small_xml, which looks like <Date><ID>27822</ID></Date>
Try this, it works.
Location: /process_data/xml/Document/Date
Expression: /process_data/small_xml/Date
Views
Replies
Total Likes
Hi,
I think you are right. The setValue will create the element if it does not exist. BUT that's not the case with the attribute. I also couldn't get the setvalue operation to create the attribute.
In your last post what are you trying to do? Do you want to assign attribute value to Date element? Creating ID element as child element of Date still has the same issue when you want to create element attribute on at runtime.
Views
Replies
Total Likes
That's a specific instance, but in general, yes, I want to be able to assign a process variable to an attribute without the attribute being specified ahead of time.
I think my options are
Views
Replies
Total Likes
Hi,
I think you have put correct options. Here are my preferences in easier to harder order.
4. Dont use attributes, only use elements
2. Create the ID attribue ahead of time, and just leave it blank ( This has to be done outside of orchestration or you'll be back to square one) (But you can always use option 3 for this to make it simpler)
3. Do the manipulation and coerce to xml
1. Use a dsc to do xml manipulation. I know XSLT can do this but I find XQuery component much easier to do xml manipulation.
Parth Pandya
Views
Replies
Total Likes