我正在使用FOP生成PDF。 PDF包含一個問卷部分,該部分在XML標籤之間有一些簡單的HTML(即<p> <strong> <em>
)。我的解決方案是將模板應用於XSL文件中的這些標籤,這些標籤可以設置<p>
標籤之間的所有內容等等。我現在設置了一個基本模板,我相信我遇到了XSL文件在XML中找到<p>
標籤的問題。我認爲,由於HTML標籤位於另一個標籤內,因此我的XSL無法按預期工作。我想知道:如何使用XSL模板來設計這些內部HTML標籤?fp/xsl文件中的Html
XML生成如下。您可以在<QuestionText>
標籤內看到HTML標籤。
<xml>
<Report>
<Stuff>
<BasicInfo>
<InfoItem>
<InfoName>ID</InfoName>
<InfoData>555</InfoData>
</InfoItem>
<InfoItem>
<InfoName>Name</InfoName>
<InfoData>Testing</InfoData>
</InfoItem>
</BasicInfo>
<SubReports title="Employee Reports">
<SubReport>
<Question>
<QuestionText>
<p>1. Are the pads secure?</p>
</QuestionText>
<AnswerText>Yes</AnswerText>
</Question>
<Question>
<QuestionText>
<p>
2. <strong>Are the pads in good shape?</strong>
</p>
</QuestionText>
<AnswerText>Yes</AnswerText>
</Question>
</SubReport>
</SubReports>
</Stuff>
</Report>
</xml>
然後,我有一個XSL模板樣式的XML
<xsl:template match="Stuff">
<fo:block>
<fo:block font-size="32pt" text-align="center" font-weight="bold">Report</fo:block>
</fo:block>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="SubReports">
<xsl:for-each select="SubReport">
<xsl:for-each select="Question">
<fo:block xsl:use-attribute-sets="question"><xsl:apply-templates /></fo:block>
<fo:block xsl:use-attribute-sets="answer"><xsl:value-of select="AnswerText" /></fo:block>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="SubReports/SubReport/Question/QuestionText">
<fo:block><xsl:apply-templates /></fo:block>
</xsl:template>
<xsl:template match="SubReports/SubReport/Question/QuestionText/p">
<fo:block padding-before="10pt"><xsl:apply-templates /></fo:block>
</xsl:template>
<xsl:template match="SubReports/SubReport/Question/QuestionText/strong">
<fo:inline font-weight="bold"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="SubReports/SubReport/Question/QuestionText/em">
<fo:inline font-style="italic"><xsl:apply-templates/></fo:inline>
</xsl:template>
是在xsl:templates
指向上的HTML標記合適的位置匹配的標籤?如果不是,我應該在哪裏指出它們?謝謝!