Author |
Message
|
Sourya |
Posted: Tue Aug 04, 2015 10:55 pm Post subject: How to select a value based on the attribute value |
|
|
Newbie
Joined: 29 Jan 2015 Posts: 5
|
Hello,
I am trying to get the last name that is "Doe" from the below message.
We have a message like this.
Code: |
<Customer>
<CustomerID>1</CustomerID>
<CustomerName>
<Salutation>Mr.</Salutation>
<Name Location="First">John</Name>
<Name Location="Last">Doe</Name>
<FullName>John Doe</FullName>
</CustomerName>
</Customer> |
Can you please help? |
|
Back to top |
|
 |
maurito |
Posted: Tue Aug 04, 2015 11:53 pm Post subject: Re: How to select a value based on the attribute value |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
Sourya wrote: |
Hello,
I am trying to get the last name that is "Doe" from the below message.
We have a message like this.
Code: |
<Customer>
<CustomerID>1</CustomerID>
<CustomerName>
<Salutation>Mr.</Salutation>
<Name Location="First">John</Name>
<Name Location="Last">Doe</Name>
<FullName>John Doe</FullName>
</CustomerName>
</Customer> |
Can you please help? |
what have you tried?. what documentation have you read? have you searched this forum ? similar questions have been asked before. |
|
Back to top |
|
 |
Sourya |
Posted: Wed Aug 05, 2015 12:17 am Post subject: Re: How to select a value based on the attribute value |
|
|
Newbie
Joined: 29 Jan 2015 Posts: 5
|
maurito wrote: |
Sourya wrote: |
Hello,
I am trying to get the last name that is "Doe" from the below message.
We have a message like this.
Code: |
<Customer>
<CustomerID>1</CustomerID>
<CustomerName>
<Salutation>Mr.</Salutation>
<Name Location="First">John</Name>
<Name Location="Last">Doe</Name>
<FullName>John Doe</FullName>
</CustomerName>
</Customer> |
Can you please help? |
what have you tried?. what documentation have you read? have you searched this forum ? similar questions have been asked before. |
Hi,
I am trying this
DECLARE cln CHARACTER '';
SET cln = THE(SELECT C.Name FROM InputRoot.XMLNSC.Customer.CustomerName as C WHERE C.Name.(XML.Attribute)Location = 'Last'); |
|
Back to top |
|
 |
maurito |
Posted: Wed Aug 05, 2015 12:36 am Post subject: Re: How to select a value based on the attribute value |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
if you are using the XMLNSC domain ( which you are ), XML.Attribute is not valid, you should use XMLNSC.Attribute.
You may also need the ITEM keyword in your SELECT statement |
|
Back to top |
|
 |
Sourya |
Posted: Wed Aug 05, 2015 1:01 am Post subject: Re: How to select a value based on the attribute value |
|
|
Newbie
Joined: 29 Jan 2015 Posts: 5
|
maurito wrote: |
if you are using the XMLNSC domain ( which you are ), XML.Attribute is not valid, you should use XMLNSC.Attribute.
You may also need the ITEM keyword in your SELECT statement |
Hi,
Tried this but did not work.
SET cln = SELECT ITEM C.Name FROM InputRoot.XMLNSC.Customer.CustomerName as C WHERE C.Name.(XMLNSC.Attribute)Location = 'Last';
SET OutputRoot.XMLNSC.Customer.LastName = cln;
The output formed like this:
<Customer/> |
|
Back to top |
|
 |
maurito |
Posted: Wed Aug 05, 2015 1:24 am Post subject: Re: How to select a value based on the attribute value |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
Sourya wrote: |
maurito wrote: |
if you are using the XMLNSC domain ( which you are ), XML.Attribute is not valid, you should use XMLNSC.Attribute.
You may also need the ITEM keyword in your SELECT statement |
Hi,
Tried this but did not work.
SET cln = SELECT ITEM C.Name FROM InputRoot.XMLNSC.Customer.CustomerName as C WHERE C.Name.(XMLNSC.Attribute)Location = 'Last';
SET OutputRoot.XMLNSC.Customer.LastName = cln;
The output formed like this:
<Customer/> |
because the path in the select statement is not pointing to the right place. You need to learn to debug the problems on your own, use a user trace with -l debug, etc.
Hint: do you know what [] means in a path ? |
|
Back to top |
|
 |
Sourya |
Posted: Wed Aug 05, 2015 2:22 am Post subject: Re: How to select a value based on the attribute value |
|
|
Newbie
Joined: 29 Jan 2015 Posts: 5
|
maurito wrote: |
Sourya wrote: |
maurito wrote: |
if you are using the XMLNSC domain ( which you are ), XML.Attribute is not valid, you should use XMLNSC.Attribute.
You may also need the ITEM keyword in your SELECT statement |
Hi,
Tried this but did not work.
SET cln = SELECT ITEM C.Name FROM InputRoot.XMLNSC.Customer.CustomerName as C WHERE C.Name.(XMLNSC.Attribute)Location = 'Last';
SET OutputRoot.XMLNSC.Customer.LastName = cln;
The output formed like this:
<Customer/> |
because the path in the select statement is not pointing to the right place. You need to learn to debug the problems on your own, use a user trace with -l debug, etc.
Hint: do you know what [] means in a path ? |
Hi,
I have already used the debug. My input message is like this:
Code: |
<Customer>
<CustomerID>1</CustomerID>
<CustomerName>
<Salutation>Mr.</Salutation>
<Name Location="First">John</Name>
<Name Location="Last">Doe</Name>
<FullName>John Doe</FullName>
</CustomerName>
</Customer> |
Observed a strange thing:
The reference C that is created after executing the SELECT does not have the attributes as in the InputRoot.
Code: |
C
Salutation:CHARACTER:Mr.
Name:CHARACTER:John
Name:CHARACTER:Doe
FullName:CHARACTER:John Doe
Customer
CustomerID:CHARACTER:1
CustomerName
Salutation:CHARACTER:Mr.
Name:CHARACTER:John
Location:CHARACTER:First
Name:CHARACTER:Doe
Location:CHARACTER:Last
FullName:CHARACTER:John Doe |
|
|
Back to top |
|
 |
maurito |
Posted: Wed Aug 05, 2015 2:30 am Post subject: Re: How to select a value based on the attribute value |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
Sourya wrote: |
maurito wrote: |
Sourya wrote: |
maurito wrote: |
if you are using the XMLNSC domain ( which you are ), XML.Attribute is not valid, you should use XMLNSC.Attribute.
You may also need the ITEM keyword in your SELECT statement |
Hi,
Tried this but did not work.
SET cln = SELECT ITEM C.Name FROM InputRoot.XMLNSC.Customer.CustomerName as C WHERE C.Name.(XMLNSC.Attribute)Location = 'Last';
SET OutputRoot.XMLNSC.Customer.LastName = cln;
The output formed like this:
<Customer/> |
because the path in the select statement is not pointing to the right place. You need to learn to debug the problems on your own, use a user trace with -l debug, etc.
Hint: do you know what [] means in a path ? |
Hi,
I have already used the debug. My input message is like this:
<Customer>
<CustomerID>1</CustomerID>
<CustomerName>
<Salutation>Mr.</Salutation>
<Name Location="First">John</Name>
<Name Location="Last">Doe</Name>
<FullName>John Doe</FullName>
</CustomerName>
</Customer>
Observed a strange thing:
The reference C that is created after executing the SELECT does not have the attributes as in the InputRoot.
C
Salutation:CHARACTER:Mr.
Name:CHARACTER:John
Name:CHARACTER:Doe
FullName:CHARACTER:John Doe
Customer
CustomerID:CHARACTER:1
CustomerName
Salutation:CHARACTER:Mr.
Name:CHARACTER:John
Location:CHARACTER:First
Name:CHARACTER:Doe
Location:CHARACTER:Last
FullName:CHARACTER:John Doe |
you have not used the user trace, and not taken any notice of the hint
Hint: do you know what [] means in a path ? |
|
Back to top |
|
 |
ganesh |
Posted: Wed Aug 05, 2015 3:19 pm Post subject: Re: How to select a value based on the attribute value |
|
|
Master
Joined: 18 Jul 2010 Posts: 294
|
Sourya wrote: |
Hi,
Tried this but did not work.
SET cln = SELECT ITEM C.Name FROM InputRoot.XMLNSC.Customer.CustomerName as C WHERE C.Name.(XMLNSC.Attribute)Location = 'Last';
|
Try this...
THE(SELECT ITEM S FROM ..............Name[] AS S WHERE S.(XMLNSC.Attribute)Location = 'Last'); |
|
Back to top |
|
 |
|