在氧气中进行DITA到PDF转换时,属性值需要以pdf格式显示

时间:2016-09-12 04:27:23

标签: xml pdf xslt dita

我的输入xml有很多元数据信息,

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE topic
  PUBLIC "com.rsicms.rsuite_te:doctypes:dita:topic" "topic.dtd">
<topic id="topic_1">
   <title outputclass="title">LANDING GEARLANDING GEAR</title>
   <titlealts>
      <navtitle>FUNCTION, DATA FOR PLANS AND DESCRIPTION</navtitle>
   </titlealts>
   <prolog>
      <metadata>
         <data-about>
            <data type="data.module.code">HSXWB-A-79-11-11-00A01-000A-D</data>
            <data type="classification">01</data>
            <data type="responsible.partner.company">F0302</data>
            <data type="originator">F0302</data>
            <data type="applicability">ALL</data>
            <data type="data.module.reference.code">TRENTXWB-A-00-00-00-01A01-022A-D</data>
            <data type="quality.assurance">tabtop</data>
            <data type="skill.level">sk01</data>
            <data type="reason.for.update">First Release</data>
            <data type="publication.code">UNKNOWN PUBLICATION</data>
         </data-about>
         <foreign outputclass="issuenum">001</foreign>
         <unknown outputclass="date">2016-01-29</unknown>
      </metadata>
   </prolog>
   <body>
      <section>
         <title>DESCRIPTION</title>
         <p>The A380 is available with two types of turbofan engines, the
Rolls-Royce Trent 900 (variants A380-841, −842 and −843F) or the Engine
Alliance GP7000 (A380-861 and −863F).  Noise reduction was an important
requirement in the A380 design, and particularly affects engine design.</p>
         <p>Landing gears<ul>
               <li>
                  <p>Nose Landing Gear</p>
               </li>
               <li>
                  <p>Wing Landing Gear (Bogie Type, 4 Wheels  - 4 Braked)</p>
               </li>
               <li>
                  <p>Body Landing Gear (Bogie Type, 6 Wheels  - 4 Braked)</p>
               </li>
            </ul>
         </p>
      </section>
      <section>
         <title>Wing Landing Gear</title>
         <p>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</p>
      </section>
      <section>
         <title>Body Landing Gear</title>
         <p>The two body landing gears have a six-wheel bogie
beam and a leg assembly that includes an oleo- pneumatic shock absorber.
A two-piece drag-stay assembly mechanically locks the leg in the extended
position.</p>
         <fig>
            <title>Landing gear</title>
            <image align="center" href="../ICN-HSXWB-A-791111-H-F0302-00001-A-001-01.tif"/>
         </fig>
      </section>
   </body>
</topic>

上述元信息将以pdf格式显示,如下所示

dita to pdf image

我使用xslt如下:

<xsl:template match="*[contains(@class,' topic/data ')]">
        <fo:block xsl:use-attribute-sets="data">
            <xsl:call-template name="commonattributes"/>
     <xsl:for-each select="data-about/data">
       <xsl:value-of select="@type"/>
<xsl:value-of select="."/> 
    </xsl:for-each>
       <xsl:text>: </xsl:text>
            <fo:inline xsl:use-attribute-sets="data__label">
                <xsl:call-template name="insertVariable">
                    <xsl:with-param name="theVariableID" select="'Data'"/>
                </xsl:call-template>
                <xsl:text></xsl:text>
            </fo:inline>
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

我希望pdf输出必须与元数据冒号的属性值一样,然后是信息,

data.module.code: HSXWB-A-79-11-11-00A01-000A-D
classification: 01
responsible.partner.company: F0302
.
.
.

我需要的是明智的。请帮助任何人。提前致谢

1 个答案:

答案 0 :(得分:0)

根据您的输入文件:

document.text()

(请注意,我添加了<?xml version="1.0" encoding="UTF-8"?> <root> <title outputclass="title">LANDING GEARLANDING GEAR</title> <titlealts> <navtitle>FUNCTION, DATA FOR PLANS AND DESCRIPTION</navtitle> </titlealts> <prolog> <metadata> <data-about> <data type="data.module.code">HSXWB-A-79-11-11-00A01-000A-D</data> <data type="classification">01</data> <data type="responsible.partner.company">F0302</data> <data type="originator">F0302</data> <data type="applicability">ALL</data> <data type="data.module.reference.code">TRENTXWB-A-00-00-00-01A01-022A-D</data> <data type="quality.assurance">tabtop</data> <data type="skill.level">sk01</data> <data type="reason.for.update">First Release</data> <data type="publication.code">UNKNOWN PUBLICATION</data> </data-about> <foreign outputclass="issuenum">001</foreign> <unknown outputclass="date">2016-01-29</unknown> </metadata> </prolog> </root> 元素。)

使用此XSLT:

root

结果:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version="2.0">

    <xsl:template match="node()|@*">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="metadata/*[position() > 1]">
        <xsl:apply-templates/>
        <fo:block>
            <b>
                <xsl:value-of select="concat(@outputclass, ':')"/>
            </b>
            <xsl:value-of select="concat(' ', current())"/>
        </fo:block>
    </xsl:template>

    <xsl:template match="data-about/*">
        <fo:block>
            <b>
                <xsl:value-of select="concat(@type, ':')"/>
            </b>
            <xsl:value-of select="concat(' ', current())"/>
        </fo:block>
    </xsl:template>

</xsl:stylesheet>

希望这有帮助!

编辑:编辑XSLT作为OP评论的答案。

EDIT2:由于OP的评论,再次更改了XSLT。