以下は、xQuery 1.0の安全なソリューションです。それはよりコンパクトにすることができますが、完全なレビューのためにこれのように残されています。
xquery version "1.0";
declare function local:encrypt($node){
'an encrypted value'
};
declare function local:decrypt($node){
'a decrypted value'
};
declare function local:traverse-and-encrypt($nodes as node()*) as node()*{
for $n in $nodes
return if($n/@encrypted = 'true')
then element{fn:node-name($n)}{
for $a in $n/@*
return if(fn:local-name($a) = 'encrypted')
then attribute {'encrypted'} {'false'}
else $a,
local:decrypt($n/text())
}
else if($n/@encrypted = 'false')
then element{fn:node-name($n)}{
for $a in $n/@*
return if(fn:local-name($a) = 'encrypted')
then attribute {'encrypted'} {'true'}
else $a,
local:encrypt($n/text())
}
else element{fn:node-name($n)}{
$n/@*,
$n/text(),
for $child in $n/*
return local:traverse-and-encrypt($child)
}
};
let $doc :=
<books>
<book>
<title encrypted="true">0234534rdf;skdlfsd</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book>
<title encrypted="false">Another book</title>
<author test='testing attributes'>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</books>
return local:traverse-and-encrypt($doc)
リターン:
<books>
<book>
<title encrypted="false">a decrypted value</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book>
<title encrypted="true">an encrypted value</title>
<author test="testing attributes">J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</books>
それは、z/OS用やLinux/UNIX/Windows上のDB2上ですか?これまでに何を試しましたか? –
あなたは、コンテンツが暗号化されている(正確に)内容を解読されているが、コンテンツがまだ暗号化されている(偽の)要素で置き換えたいとしますか?この行動を指定し、重度のカウンセリングを行うデザイナーを探してください。 –
コードはデータベースパッケージとしてデータベース内で実行されているので、私はxqueryを使用しようとしていますが、これについてどうやってどうやっていくのかちょっと困惑しています。主な問題は、私が列が暗号化されていることをあらかじめ知っているわけではないので、手続きは一般的でなければならないということです。 –