아래 XML이 있습니다.다른 경우로 구분하고 연결하십시오.
<orderedlist type="manual">
<item num="1."><para>identify the issues in dispute;</para></item>
<item num="1.1"><para>explore and generate options;</para></item>
<item num="1.1.1"><para>communicate with one another; and/or</para></item>
<item num="(i)"><para>copy of the cancellation of employment pass; and</para></item>
<orderedlist>
여기에 내가 item-num
의 모든 .
-
에 번역 및 .
이전에 내가 해결책을받은 나는 not(ends-with(./@num,'.'))
을 사용한 후 일부 번호 또는 기간이 다른 태그로 둘러싸 싶다. 그것도 괜찮 았던 점까지, 최근에 나는 에있는 값이 (i), i, a, a)
과 같은 조건을 가지고 있으며 새로운 tag
을 얻는 상황 (위의 XML에서 4 번째 item num
)을 발견했습니다. 아래는 내 XSL 템플릿입니다. 내가 X.X
X.X.X
를 포맷보다
<xsl:template name="orderedlist" match="orderedlist">
<ol class="eng-orderedlist orderedlist">
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="item">
<xsl:call-template name="paran"></xsl:call-template>
</xsl:template>
<xsl:template name="paran">
<xsl:apply-templates select="./para/node()[1][self::page]" mode="first"/>
<li class="item">
<div class="para">
<xsl:choose>
<xsl:when test="not(ends-with(./@num,'.'))">
<a name="{translate(./@num,'.','-')}"/>
<span class="phrase">
<xsl:value-of select="./@num"></xsl:value-of>
</span>
</xsl:when>
<xsl:when test="./@num">
<span class="item-num">
<xsl:value-of select="./@num"></xsl:value-of>
</span>
</xsl:when>
</xsl:choose>
<xsl:apply-templates/>
</div>
</li>
</xsl:template>
<xsl:template match="page[not(preceding-sibling::node()[not(self::text()) or normalize-space()])]"/>
여기에 내가 다른 숫자의 주위에
phrase
를 원하지 않는다.
이 호의 데모는 here입니다.
어떻게 해결할 수 있는지 알려 주시기 바랍니다.
감사
예상되는 결과는 무엇입니까? – helderdarocha
지난 몇 주 동안 여러 가지 매우 비슷한 질문을했습니다. 이전에 XSLT 2.0을 사용하고 있다고 지적 했으므로 [이전 질문 중 하나에 대한 내 대답]에 대한 의견에서 제안한 내용을 다시 한 번 추천합니다 (http://stackoverflow.com/a/24040621/592139).) - 당신이 찾고있는 구조는 정규 표현식으로 콤팩트하게 표현 될 수 있으므로'matches' 함수를 사용하여 그것을 테스트 할 수 있습니다. –
안녕하세요 @helderdarocha, 예상 출력은'XX' 또는'XXX' 형식의'item num'과 떨어져 있고, 다른 모든 item-num은'' 그러나 ' – user2423959