1

XML タグを見つけて XSL に置き換えることに成功しましたが、XSL が機能しない可能性があることがわかりました。

ソース XML:

<article>
    <parastyles>
        <parastyle name="Headline Bold" uid="876"/>
        <parastyle name="Head babies-recipe" uid="877"/>
        <parastyle name="Byline Paper" uid="885"/>
        <parastyle name="Byline Name" uid="886"/>
        <parastyle name="Body Copy" uid="904"/>
    </parastyles>
    <charstyles>
        <charstyle name="[None]" uid="103"/>
    </charstyles>
    <story name="body">
        <runs>
            <run p="886" c="103">By AUTHOR NAME
                <eol/>
            </run>
                <run p="885" c="103">Local Writer
                <eol/>
            </run>
            <run p="904" c="103">CITY — Borough Police en
                <eol hyphenated="true"/>
                countered three men in separate cases
                <eol/>
                recently who all claimed they had for
                <eol hyphenated="true"/>
                gotten they were carrying drugs or drug
                <eol/>
                paraphernalia until an officer started
                <eol/>
                asking questions.
            </run>
            <run p="877" c="103">
                Forgot joints
                <eol/>
            </run>
            <run p="904" c="103">
                In another case, City
                <eol/>
                Police were called to a home
                <eol/>
                on LaSalle Street March 30
                <eol/>
                for a report of a man banging
                <eol/>
                on the door.
                <eol/>
            </run>
            <run p="877" c="103">
                Forgot pipe
                <eol/>
            </run>
            <run p="904" c="103">
                In a third case, Ptlm. Raf
                <eol hyphenated="true"/>
                ferty spotted a young man
                <eol/>
                running along West Second
                <eol/>
                Street and ducking into an
                <eol/>
                area near the Salvation Army
                <eol/>
                drop-off on March 28 around
                <eol/>
                1:40 a.m.
                <eol/>
            </run>
        </runs>
    </story>
</article>

私のXSLは次のとおりでした:

<xsl:template match="run[@p='877']">
    <xsl:text>&lt;strong&gt;</xsl:text><xsl:value-of select="."/><xsl:text>&lt;/strong&gt;</xsl:text>
</xsl:template>

これにより、選択した行が目的のタグでラップされました。ただし、本当に必要なのは、「Head baby-recipe」という名前の行を でラップすることです。これまでのところ、それらはすべて「877」の uid を持っており、run[@p='877'] を使用すると機能しました。ただし、uid が「877」でないインスタンスが存在する可能性があります。そのため、名前が「Head baby-recipe」である parastyle の uid に p が等しい a を探すために、'match' ステートメントが必要です。これはもう少し複雑で、そのために機能する XSL を思いつくことができませんでした。

どんな助けでも大歓迎です!

4

1 に答える 1

1

それはそのようなものでなければなりません(「バイライン名」の場合):

run[@p=/article/parastyles/parastyle[@name='Byline Name']/@uid]
于 2013-05-07T17:33:25.840 に答える