0

属性の内容をファイルに格納する xquery 3.0 関数を作成しました。問題は、ファイル内で 1 行だけがフォーマットされていることです。つまり、属性値を取得するタグがたとえば

...
<tag attr=" example line 1
            example line 2
"/>...

見つけたファイルに

example line 1 example line 2

一方、私の望ましい出力は

example line 1`
example line 2

何を指示してるんですか?私はexistdbを使用しています。よろしくお願いします。

4

2 に答える 2

1

XQuery は、要素ノード コンストラクターで属性を処理するときの XML パーサーの動作を模倣します。XML 仕様で定義されている属性値の正規化を適用し、これにより改行が失われます。のように記述することで属性値に改行を強制することができます&#xa;が、通常、改行が重要な属性を持つことは適切な XML 設計ではありません。(XSLT は XPath 式を属性に入れ、これらはしばしば複数行になる可能性があるため、XSLT はこのルールが問題を引き起こす例です)。

于 2015-11-22T10:11:04.257 に答える
0

もちろん!私のexistdbバージョンは2.2です。

xquery version "3.0";
declare boundary-space preserve;

declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace xmldb="http://exist-db.org/xquery/xmldb";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare option output:indent "yes";
import module namespace file="http://exist-db.org/xquery/file";




let $log-in := xmldb:login("/db", "admin", "admin")


for $k in (35,36,37)

let $AppletName := fn:doc(fn:concat('/db/project/AppletA_',$k,'.xml'))//APPLET/@NAME/string()
let $collection := fn:concat('xmldb:exist:/db/project/Scripts_',$k)

let $node :=(<APPLET_SCRIPTS>{
                    for $i in fn:doc(fn:concat('/db/project/AppletA_',$k,'.xml'))//APPLET_SERVER_SCRIPT
                        let $MethodName := $i/@NAME
                        let $MethodScript := string($i/@SCRIPT)

                        let $file-name :=  fn:concat($MethodName,'.js')
                        let $store :=  xmldb:store($collection,$file-name, $MethodScript) 

                            return <div>{$MethodScript}</div>
            }</APPLET_SCRIPTS>)

return $node   

xml のフラグメントは次のとおりです。

スクリーンショット xml フラグメント

作成されるファイルの内容は、次の 1 行の文字列です。

function Prova() { try { var sVal = TheApplication().InvokeMethod("LookupValue","FS_ACTIVITY_CLASS","CIM_FAC18"); var recordFound = searchRecord(sVal); if(!recordFound) { this.InvokeMethod("NewRecordCustom"); this.BusComp().SetFieldValue("クラス",sVal); this.BusComp().WriteRecord(); } } catch(e) { throw(e); } 最後に { sVal = null; } }

于 2015-11-21T12:47:07.703 に答える