1

関数のXPATHフィルターをパラメーター化したいのですが、すべての結果が必要であることを示す機会が欲しいです。明確な例

declare function search-by-author($author as xs:string*) as element()*{
   /Data/Books[@autor=$author]
};

search-by-author(()) -> If null no results even if some books did not have @autor attr
search-by-author('') -> If empty, only shows those books with @author=''
search-by-author(('a','b')) -> Returns books by authors 'a' or 'b'
search-by-author(*) -> THIS MY CURRENT PROBLEM. 

どうすればこれをエミュレートできますか?*を変数として渡すための特別なパラメータまたは構文はありますか?

 $var = * --> /Data/Books[@autor=$var] 

また

 $var = EMPTY --> /Data/Books[@autor=$var] --> /Data/Books[@autor]

ありがとうございました!

4

1 に答える 1

1

declare function search-by-author($author as xs:string*) as element()*{
   /Data/Books[$author='*' or @autor=$author]
};

できるよ

search-by-author('*')
于 2012-07-12T23:07:09.413 に答える