キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 
cancel
468
閲覧回数
0
いいね!
0
コメント
Asami Agarie
Cisco Employee
Cisco Employee

 

 

はじめに

Template を使ったサービスで、以下のような if タグから条件分岐させるケースにおいて、ある2通りの {expression} について解説します。

 

<?if {expression}?>
   ... 
<?elif {expression}?>
   ... 
<?else?>
...
<?end?>

 

boolean と XPath Evaluation

このような Template を使ったサービスがあるとします

 

-YANG 
}
leaf xxx {
 type boolean;
 default false;
}

-XML Template
#1
<?if {abc}?>
 <some config ... />
<?end?>

#2
<?if {abc = 'true'}?>
 <some config ... />
<?end?>

 

#1の例では、XPath evalution の結果は boolean true になります。

 

xpath: template int-test-template: evaluating: string(boolean(abc))
xpath: template int-test-template: result: true 

 

"abc" がパスとして存在しているか (exists) 否かを評価しています。#2の例では、テンプレート適用時に abc を指定するまたは abc をデフォルト値にしている場合にのみ true と評価されます。

 

xpath: template int-test-template: evaluating: string(boolean(abc ='true'))
xpath: template int-test-template: result: true 


xpath: template int-test-template: evaluating: string(boolean(abc ='true'))
xpath: template int-test-template: result: false


 

#1 の結果については XML Path Language ドキュメンテーションに説明がありますので、そちらをご参照下さい。

一部抜粋

The boolean function converts its argument to a boolean as follows:

a number is true if and only if it is neither positive or negative zero nor NaN
a node-set is true if and only if it is non-empty
a string is true if and only if its length is non-zero
an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type

 

 

Getting Started

検索バーにキーワード、フレーズ、または質問を入力し、お探しのものを見つけましょう

シスコ コミュニティをいち早く使いこなしていただけるよう役立つリンクをまとめました。みなさんのジャーニーがより良いものとなるようお手伝いします