1

現在、次の XML があります。

<Rowsets>
    <Rowset>
        <Row>
            <DrilldownDepth>0</DrilldownDepth>
            <ScheduleWeek>---</ScheduleWeek>
            <ABC>---</ABC>
            <PQR>1500</PQR>
            <XYZ>15000</XYZ>
            <Quant>285</Quant>
        </Row>
        <Row>
            <DrilldownDepth>1</DrilldownDepth>
            <ScheduleWeek>12</ScheduleWeek>
            <ABC>---</ABC>
            <PQR>1500</PQR>
            <XYZ>15000</XYZ>
            <Quant>285</Quant>
        </Row>
        <Row>
            <DrilldownDepth>2</DrilldownDepth>
            <ScheduleWeek>12</ScheduleWeek>
            <ABC>SUPER</ABC>
            <PQR>100</PQR>
            <XYZ>200</XYZ>
            <Quant>300</Quant>
        </Row>
        <Row>
            <DrilldownDepth>2</DrilldownDepth>
            <ScheduleWeek>12</ScheduleWeek>
            <ABC>Duper</ABC>
            <PQR>100</PQR>
            <XYZ>200</XYZ>
            <Quant>300</Quant>
        </Row>
        <Row>
            <DrilldownDepth>2</DrilldownDepth>
            <ScheduleWeek>12</ScheduleWeek>
            <ABC>Fun</ABC>
            <PQR>100</PQR>
            <XYZ>200</XYZ>
            <Quant>300</Quant>
        </Row>
        <Row>
            <DrilldownDepth>2</DrilldownDepth>
            <ScheduleWeek>7</ScheduleWeek>
            <ABC>SUPER</ABC>
            <PQR>100</PQR>
            <XYZ>200</XYZ>
            <Quant>300</Quant>
        </Row>
        <Row>
            <DrilldownDepth>2</DrilldownDepth>
            <ScheduleWeek>7</ScheduleWeek>
            <ABC>Duper</ABC>
            <PQR>100</PQR>
            <XYZ>200</XYZ>
            <Quant>300</Quant>
        </Row>
        <Row>
            <DrilldownDepth>2</DrilldownDepth>
            <ScheduleWeek>8</ScheduleWeek>
            <ABC>SUPER</ABC>
            <PQR>100</PQR>
            <XYZ>200</XYZ>
            <Quant>300</Quant>
        </Row>
    </Rowset>
</Rowsets>

今、必要なのは<Row>where<DrilldownDepth>2</DrilldownDepth><ScheduleWeek>12</ScheduleWeek>. リピーター/ループを使用して実現できますが、Xpath または XSLT を使用して実現する必要があります。したがって、この問題についての助けをいただければ幸いです。

ソッツ

4

2 に答える 2

0

'および'演算子の代わりに、2番目の述語を使用することもできます。どちらが良いかは個人的なスタイルに依存しますが、SOに関する多くの回答を見ると、複数の述語の方法が一般的な選択肢であることがわかります。

このように見えます...

 /Rowsets/Rowset/Row[DrilldownDepth='2'][ScheduleWeek='12']

注:これは、リテラル数の前後に引用符がある場合とない場合で同様に機能します。なしの方が少し読みやすいかもしれません。とは少し効率的かもしれません。繰り返しますが、これはスタイルの選択です。

于 2012-06-26T03:36:36.633 に答える
0

次の XPath ステートメントでは、述語フィルターを使用して、指定された基準を満たす子要素を含む Row 要素を選択します。

/Rowsets/Rowset/Row[DrilldownDepth=2 and ScheduleWeek=12]

XSLT で適用される値に変数を使用する:

<xsl:variable name="depth">2</xsl:variable>
<xsl:variable name="week">12</xsl:variable>
<xsl:apply-templates select="/Rowsets/Rowset/Row[DrilldownDepth=$depth and ScheduleWeek=$week]"/>
于 2012-06-26T01:24:28.150 に答える