ParameterSelector

ParameterSelectorについて.

これを使えば,パイプライン内においてパラメータで分岐できる.

参考(本家傘下?)

以下の例は上記リンク先から拝借.

例:


<map:match pattern="*.xml">
<map:act type="MyAction">
<map:generate src="{../1}.xml"/>

<map:select type="parameter">
<map:parameter name="parameter-selector-test" value="{MyRegion}"/>

<!-- executes iff the value of MyRegion equals
"United States" (without quotes) -->
<map:when test="United States">
<map:transform src="stylesheets/us.xsl"/>
</map:when>

<map:when test="South_America">
<map:transform src="stylesheets/southamerica.xsl"/>
</map:when>

<map:when test="Europe">
<map:transform src="stylesheets/europe.xsl"/>
</map:when>

<map:otherwise>
<map:transform src="all_others.xsl"
</map:otherwise>

</map:select>
</map:act>
<map:serialize/>
</map:match>


変数{MyRegion}の値でXSLTを変える例.Localizationに使えるかもしれない.


上記例とは別件で map:generate で使ってみたところ map:otherwise が無いと駄目らしい.
これは,generate のソースが無いと,以降のコンポーネントが受けるはずのSAXイベントが無いという事態を防ぐためと思われる.
上記のように transform を分けている場合は未調査.まあ,sitemap.xmapのスキーマを調べるだけですが.