2017-02-09 11 views
0

У меня есть входной XML, который выглядит, как этотESQL, как использовать оператор выбора для извлечения значения из входного XML

<log> 
    <line> 
     <id>1</id> 
    <line> 
     <id>2</id> 
    <otherLine> 
     <id>2</id> 
     <field> 
      12345-67 
     </field> 
    </otherLine> 
</log> 

Что делать в ESQL в основном перебирать каждый <line> элемент и я хочу получить значение от <otherLine>, где совпадают значения <id>.

У меня есть такой код:

declare inDoc reference to InputRoot.XMLNSC.log; 
declare line reference to inDoc; 
declare fieldValue character; 

move line firstchild name 'line'; 
while lastmove(line) do 

    set fieldValue = select r.field from inDoc.otherLine[] as r where r.id = line.id; 
    -- I want this to be null when hitting the line with <id>1</id> and 12345-67 and hitting the line with <id>2</id> 

    move line nextsibling name 'line'; 
end while 

я получаю следующее сообщение об ошибке при попытке развернуть код:

BIP2497E: (MyApp_flow.Main, <line number of select statement>) : Illegal data type for target. A list field reference is required. 

The expression supplying the target must evaluate to a value of a suitable type. The given expression cannot possibly do so. 

Correct the syntax of your ESQL expression in node 'MyApp_flow.Main', around line and column '<line number of the select statement>', then redeploy the message flow. 

Я задаюсь вопросом, что правильный путь для достижения этой цели в ESQL будет

Благодаря

ответ

1

решение заключается в использовании the, item и fieldvalue в выписке

set fieldValue = the(select item fieldvalue(r.field) from inDoc.otherLine[] as r where r.id = line.id);