<段落 类型="普通">
<文本>"Dublin officially twinned with Beijing" proclaimed The Irish Times last weekend, as the city's Lord Mayor </文本>
<B>Gerry Breen</B>
<文本> swept through Beijing to sign a sister cities' agreement between the two capitals.</文本>
</段落>
  
<段落 类型="普通">
  <B>BEIJING—</B> 
  <文本>Two Chinese business tycoons who attended previous Warren Buffett auction lunches called the experience informative and inspiring, according to earlier media reports.</文本> 
</段落>   xslt如何解析<段落>元素下子的先后顺序,如何判断当前是<文本>或者是<B>等等!不甚感激!

解决方案 »

  1.   

    xslt用xpath匹配元素
    //B 匹配B元素
    //文本 匹配所有“文本”元素
    //段落/* 匹配B或“文本”元素,这些元素按原来次序依次排列
      

  2.   

    那在xslt中要如何进行判断呢?现在要把这个xslt写成一个固定的一个xslt,依次把很多的xml转换成统一的html!
      

  3.   

     <xsl:for-each select="文章内容/正文/段落" >
                            <xsl:choose>
                              <xsl:when test="B"><!-- 判断段落刚开始是<B></B>标签-->
                      <p>&#160;&#160;&#160;
                       <b><xsl:value-of  select="B[1]"/></b>
                        <xsl:value-of select="文本[1]"/>
                      </p> 
                              </xsl:when>
                               <xsl:when test="文本"><!-- 判断段落刚开始是<文本></文本>标签-->
                      <p>&#160;&#160;&#160;
                        <xsl:value-of select="文本[1]"/>
                      </p> 
                              </xsl:when>
                               <xsl:when test="I"><!-- 判断段落刚开始是<I></I>标签-->
                      <p>&#160;&#160;&#160;
                        <i><xsl:value-of select="I[1]"/></i>
                      </p> 
                              </xsl:when>