user2423959
user2423959

Reputation: 834

matching first child from a node

I've the below XML code.

 <chapter>
  <section>
   <section level="sect2">
    <title>I<content-style format="smallcaps">ntroduction to</content-style> H<content-style format="smallcaps">ong</content-style> K<content-style format="smallcaps">ong’s</content-style> A<content-style format="smallcaps">rbitration</content-style> R<content-style format="smallcaps">egime</content-style></title>
    <figure><caption><para>Hong Kong White Book Image</para></caption><graphic href="HKWB2014_Part_U1.pdf"/></figure>
    <para id="t2_HKWB2014_Part_U1_pgfId-2"><phrase>U1/0</phrase>This section is divided into five parts:</para>
  </section>
 </section>
</chapter>

here i need to match the first child of <section level="sect2">. i'm using the below xslt condition from chapter.

<xsl:when test="./section/section[1]/para[1]/phrase">

the above statement doesn't relate to my XML code, but i want to check if the xml is like the below format.

--Section
  --Section
    --para
      --phrase

the first child of the section should be a para/phrase, but not title. please let me know how i can match this.

Thanks

Upvotes: 0

Views: 25

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167716

Use <xsl:when test="section/section[1]/*[1][self::para[phrase]]">.

Upvotes: 1

Related Questions