Author |
Message
|
dyson |
Posted: Wed Apr 24, 2013 5:42 pm Post subject: XML - setting a wildcard attribute from an extension |
|
|
 Apprentice
Joined: 04 Apr 2011 Posts: 45
|
e.g. The Total element has a wildcard attribute which I'm trying to set.
Code: |
SET TRANSACTION.*:Total=5.99;
SET TRANSACTION.*:Total.(XMLNSC.Attribute)*:Element.*:TotalType='Grand'; |
The above passed thru the validation node successfully but the XML generated doesn't include the attribute i.e. the output is: <Total>5.99</Total>.
I was thinking it would be:
<Total Element.TotalType="Grand">5.99</Total>
Not sure if it's the code or how the TotalType attribute was defined in the xsd? |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Wed Apr 24, 2013 9:34 pm Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Problem is in your code. Study ESQL field referencing and search from web if XML attributes can have namespaces.
--
Marko |
|
Back to top |
|
 |
Esa |
Posted: Wed Apr 24, 2013 10:45 pm Post subject: Re: XML - setting a wildcard attribute from an extension |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
dyson wrote: |
SET TRANSACTION.*:Total.(XMLNSC.Attribute)*:Element.*:TotalType='Grand';[/code]
|
If the attribute name has special characters like '.', it should be enclosed with quotes, like
Code: |
SET TRANSACTION.(XMLNSC.Attribute)"Element.TotalType" = 'Grand'; |
An attribute with a namespace may be a little challenging, maybe something like TRANSACTION.(XMLNSC.Attirbute)*:"Element.Type" could work.
But your code is for an attribute that has two namespaces, one of them in the middle of the attribute name. That is not valid XML.
As if you had an element like this:
Code: |
<ns1:TRANSACTION ns1:Element.ns1:Type='Grand'/> |
|
|
Back to top |
|
 |
kimbert |
Posted: Thu Apr 25, 2013 2:05 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Esa is correct. Looks like a simple typo in your field reference.
A couple of points to clarify:
- setting a namespace on an attribute is the same as setting it on an element. Not sure why one would be harder than the other.
- this is nothing to do with wildcards. It's a simple ESQL coding error. |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Thu Apr 25, 2013 2:38 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Yes kimbert, you are right. I was remembering and didn't check the exact clause
Quote: |
It is only logical that namespaces are mostly about elements and that attributes don’t need to be in a namespace. |
XML attributes and namespace are quite a well described here
--
Marko |
|
Back to top |
|
 |
kimbert |
Posted: Thu Apr 25, 2013 2:49 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Yes, I can see how that article could confuse people.
The XML specification does allow attributes to have namespaces, and there are very good reasons for that. Imagine that your XML schema defines an attribute called 'type'. There is a commonly used attribute called 'type' in the xsi namespace. Without namespaces on attributes, it would be impossible to distinguish between xsi:type="myns:mySimpleType" and dogs:type="labrador". |
|
Back to top |
|
 |
dyson |
Posted: Thu Apr 25, 2013 8:10 am Post subject: |
|
|
 Apprentice
Joined: 04 Apr 2011 Posts: 45
|
|
Back to top |
|
 |
|