내가 가진 노드가 자식 노드에 text
및 child node
변환 텍스트가 포함 된 경우 의미 모든 노드가이 문서를 변환하는 방법xquery update를 사용하여 노드 내부의 텍스트를 자식 노드로 변환하는 방법은 무엇입니까?
<root>
<first>
First Level
<second>
second level
<third>
Third Level
</third>
</second>
<second2>
another second level
</second2>
</first>
</root>
같은 XML 문서는 XQuery 업데이트를 사용 (의이 childtext 말을하자)
<root>
<first>
<childtext>First Level</childtext>
<second>
<childtext>second level</childtext>
<third>
Third Level
</third>
</second>
<second2>
another second level
</second2>
</first>
</root>
그리고 여기 내가 뭘하려 :
let $a :=
<root>
<first>
First Level
<second>
second level
<third>
Third Level
</third>
</second>
<second2>
another second level
</second2>
</first>
</root>
return
copy $i := $a
modify (
for $x in $i/descendant-or-self::*
return (
if($x/text() and exists($x/*)) then (
insert node <childtext>
{$x/text()}
</childtext> as first into $x
(: here should be some code to delete the text only:)
) else()
)
)
return $i
형제 노드가있는 텍스트를 삭제할 수 없습니다.
먼저 값 text()를 사용하여 노드 "childtext"를 만들 수 있습니다. 이제는 여전히 오래된 텍스트를 삭제해야합니다.>이 텍스트 만 삭제할 수 없습니다. 값을 비우려면 다른 자식 노드도 제거해야합니다. 달러 (A $)하자 : ((=이 $ A 수정 $ $의 I/하위 - 또는 - 자체 :: * 대가로 x의 을 = .... 반환 복사 $ 난 내가하려고 여기에서 –
경우 ($ X/텍스트()와 존재 ($ X/*)) 다음 ( 삽입 노드 {$ X/텍스트()}로 처음 $의 X에 , (: 여기 어떻게 든이 삭제해야 다음 단계로 텍스트 또는 업데이트 : ) 다른 ( ) ) 는) $ 내가 –
질문 (의 헥타르에이 코드를 수정하십시오 반환 여기에서 읽을 수 있음), 코드의 일부를 생략하지 않으므로 더 이상 실행되지 않습니다 ('let $ a : = ....'는 작동 코드가 아닙니다). 현재 코드에 어떤 문제점이 있습니까? –