XSLTを初めて使用しており、XMLを使用する新しい作業が得られました& XSLT。XSLを使用した複雑なXML処理
私はahs lotに子とその子を持つxmlファイルを持っています。
xslを使って私がporcess xmlしたとき、それは親ノードではうまく動作しますが、子ノードでは何もデータが得られません。 XMLファイル:
<jrnl:bodytext>
<level>
<bodytext>
<pgrp>
<heading>
<title>
<emph typestyle="bf">1. Orange</emph>
</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
<p>
<text>Paragraph 2<text>
</p>
<p>
<text>Paragraph 3</text>
</p>
</pgrp>
<pgrp>
<heading>
<title>
<emph typestyle="bf">2. Apple </emph>
</title>
</heading>
<pgrp>
<heading>
<title>(a) Introduction</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
</pgrp>
<pgrp>
<heading>
<title>(b) The Facts</title>
</heading>
<p>
<text>Paragraph 2</text>
</p>
<p>
<text>Paragraph 3</text>
</p>
</pgrp>
<pgrp>
<heading>
<title>(c) Mango</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
<p>
<text>Paragraph 2</fnr>
</text>
</p>
<p>
<text>Paragraph 3</text>
</p>
</pgrp>
<pgrp>
<heading>
<title>(d) Misreading of Authority</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
<p>
<text>Paragraph 2</text>
</p>
<p>
<text>Paragraph 3</text>
</p>
</pgrp>
<pgrp>
<heading>
<title>(e) The case</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
<p>
<text>Paragraph 2
</text>
</p>
<p>
<text>Paragraph 3</text>
</p>
</pgrp>
</pgrp>
<pgrp>
<heading>
<title>
<emph typestyle="bf">3. Principles</emph>
</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
<p>
<text>Paragraph 2</text>
</p>
<p>
<text>Paragraph 3</text>
</p>
<p>
<text>Paragraph 4</text>
</p>
</pgrp>
<pgrp>
<heading>
<title>
<emph typestyle="bf">4. Guidelines </emph>
</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
<p>
<text>Paragraph 2</text>
</p>
<p>
<l>
<li>
<lilabel>(i)</lilabel>
<p>
<text>Paragraph 2.1</text>
</p>
</li>
</l>
</p>
<p>
<text>Pragraph 3</text>
</p>
</pgrp>
<pgrp>
<heading>
<title>
<emph typestyle="bf">5. Conclusion</emph>
</title>
</heading>
<p>
<text>Paragraph 1</text>
</p>
</pgrp>
</bodytext>
</level>
</jrnl:bodytext>
今私はすべて、見出しとテキストデータを取得します。私はすべての外側のデータを取得することができますが、私は自分の子供のデータを取得することはできません。ここで
は、XSLコード
<xsl:for-each select="//jrnl:bodytext/level/bodytext/pgrp">
<xsl:text>$T$=</xsl:text>
<xsl:value-of select="heading/title/emph"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="p">
<xsl:text>$T</xsl:text>
<xsl:value-of select="text"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
はこの質問を拡張することです、今示唆したように、私は同じコードを試してみましたが、何も起こりません。
私が試したことを以下に見てください。私が得た
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:jrnl="http://www.abc.com/glp/jrnl" >
<xsl:template match="//jrnl:bodytext">
<xsl:for-each select="level/bodytext">
<xsl:for-each select="pgrp">
<xsl:text>$T$=</xsl:text>
<xsl:value-of select="heading/title/emph"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="p">
<xsl:text>$T</xsl:text>
<xsl:value-of select="text"/>
<xsl:text>
</xsl:text> </xsl:for-each>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
とどのような出力
$T$=1. Orange
$TParagraph 1
$TParagraph 2
$TParagraph 3
$T$=2. Apple
$T$=3. Principles
$TParagraph 1
$TParagraph 2
$TParagraph 3
$TParagraph 4
$T$=4. Guidelines
$TParagraph 1
$TParagraph 2
$T
$TPragraph 3
$T$=5. Conclusion
$TParagraph 1
私はこのケースでの出力には、私は1つのだけのエントリすなわち$ T $ = 2を得たのに対し、テキストが1より大きいPGRP 2(アップル)必見のためentris 。アップル
入力値と試したコードを追加してください –
自分のコードを追加しました。 – Vish