简体   繁体   English

如何将XML / XSLT中的嵌套tabcontrol元素转换为XSL-FO

[英]How do I transform nested tabcontrol elements in XML/XSLT to XSL-FO

I have a dynamic xml record that uses tabcontrols and tabpages and I need to create xsl-fo. 我有一个使用tabcontrols和tabpages的动态xml记录,我需要创建xsl-fo。 However, I cannot find any references to solutions online. 但是,我找不到在线参考解决方案。 An excerpt from the xml is as follows: xml的摘录如下:

<Textbox ID="Textbox_Comments_Multiline_5" Field="Case Comments:" Value=""   Size="600" Length="" Extender="TextBoxWatermark~  " Align="left" LabSize="" HelpMessage="" RPosition="0" isSpecific="true" Position="505" DefaultValue="" />
<Tabcontrol ID="Tabcontrol1" Position="700">
<Tabpage ID="Tabpage_Notification" Field="NOTIFICATION" Size="" Extender="" Align="" HelpMessage="" Position="1000">
  <Linebreak ID="Linebreak_Notification_1" RPosition="0" Position="1001" />
  <Combobox ID="Combobox_HPTOffice" Field="Health Protection Office:" Value="Please select" ValuesLookup="HPTOffice" Size="" Length="" Extender="" Align="" LabSize="180" HelpMessage="" RPosition="0" Position="1010" />
  <Linebreak ID="Linebreak_Notification_5" RPosition="0" Position="1011" />
  <Datebox ID="Datebox_NotificationDate" Field="Notification Date:" Value="1900-01-01" Size="100" Length="" Extender="" Align="right" LabSize="180" HelpMessage="" RPosition="0" Position="1020" />
  <Linebreak ID="Linebreak_Notification_10" RPosition="0" Position="1021" />
  <Textbox ID="Textbox_NotifiedBy" Field="Notified by:" Value="" Size="400" Length="" Extender="TextBoxWatermark~  " Align="left" LabSize="180" HelpMessage="" RPosition="0" Position="1030" />
  <Linebreak ID="Linebreak_Notification_15" RPosition="0" Position="1031" />
  <Textbox ID="Textbox_NotifierDesignation_Multiline_3" Field="Notifier Designation:" Value="" Size="600" Length="" Extender="TextBoxWatermark~  " Align="left" LabSize="" HelpMessage="Notifier details" RPosition="0" Position="1040" />
  <Linebreak ID="Linebreak_Notification_20" RPosition="0" Position="1041" />
  <Linebreak ID="Linebreak_Notification_25" RPosition="0" Position="1042" />
  <Textbox ID="Textbox_ResponsibleClinicianDetails_Multiline_5" Field="Responsible Clinician Details:" Value="" Size="600" Length="" Extender="TextBoxWatermark~  " Align="left" LabSize="" HelpMessage="" RPosition="0" Position="1050" />
  <Linebreak ID="Linebreak_Notification_30" RPosition="0" Position="1051" />
  <Linebreak ID="Linebreak_Notification_35" RPosition="0" Position="1052" />
  <Combobox ID="Combobox_SourceOfSpecimen" Field="Source Of Specimen:" Value="Please select" ValuesLookup="SourceOfSpecimen" Size="" Length="" Extender="" Align="" LabSize="180" HelpMessage="" RPosition="0" Position="1060" />
  <Linebreak ID="Linebreak_Notification_40" RPosition="0" Position="1061" />
  <Textbox ID="Textbox_SourceOfSpecimenOtherSpecify" Field="If other specify:" Value="" Size="300" Length="" Extender="TextBoxWatermark~  " Align="left" LabSize="180" HelpMessage="" RPosition="0" Position="1070" />
  <Linebreak ID="Linebreak_Notification_45" RPosition="0" Position="1071" />
  <Combobox ID="Combobox_Laboratory_InitialNotification" Field="Source Laboratory:" Value="Please select" ValuesLookup="Laboratory" Size="" Length="" Extender="" Align="" LabSize="180" HelpMessage="" RPosition="0" Position="1080" />
  <Linebreak ID="Linebreak_Notification_50" RPosition="0" Position="1081" />
  <Linebreak ID="Linebreak_Notification_60" RPosition="0" Position="1091" />
</Tabpage>

There is not a lot of information given in your source XML you present nor in trying to understand what the desired "look" of the output is. 在您呈现的源XML中,或者试图理解输出的期望“外观”时,并没有提供太多信息。

PDF Acroform fields are support in RenderX XEP with the proper license and ensuring you add the rx: Extension namespace. PDF Acroform字段在具有适当许可证的RenderX XEP中受支持,并确保您添加了rx:Extension命名空间。 I just did a simple layout using the XSL below (note I added tags to you XML to make it a complete document as it is only a fragment): 我只是使用下面的XSL进行了简单的布局(请注意,我为XML添加了标签以使其成为完整的文档,因为它只是一个片段):

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rx="http://www.renderx.com/XSL/Extensions" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
    <fo:root>
        <fo:layout-master-set>
            <fo:simple-page-master master-name="page" page-width="8.5in" page-height="11in"
                margin-top="0.5in" margin-bottom="0.5in">
                <fo:region-body region-name="body" margin-left="0.5in" margin-right="0.5in"/>
            </fo:simple-page-master>
        </fo:layout-master-set>
        <fo:page-sequence master-reference="page">
            <fo:flow flow-name="body">
                <xsl:apply-templates/>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>
<xsl:template match="Tabcontrol">
    <fo:block margin="10pt" border-top="3pt solid silver">
        <xsl:apply-templates/>
    </fo:block>
</xsl:template>
<xsl:template match="Tabpage">
    <fo:block margin-left="10pt" margin-top="3pt">
        <xsl:value-of select="@Field"/>
    </fo:block>
    <fo:block margin="10pt" border="1pt solid black">
        <xsl:apply-templates/>
    </fo:block>
</xsl:template>
<xsl:template match="Linebreak">
    <fo:block>
        <fo:leader/>
    </fo:block>
</xsl:template>
<xsl:template match="Combobox">
    <fo:block margin-left="10pt" margin-right="10pt"  keep-with-next.within-page="always">
        <xsl:value-of select="@Field"/>
    </fo:block>
    <fo:block-container  margin-left="10pt" margin-right="10pt">
        <rx:pdf-form-field name="{@ID}">
            <rx:pdf-form-field-combobox background-color="wheat"
                border-width="1pt" border-style="solid"
                border-color="silver">
                <!-- You would need to define your selections here -->
                <rx:pdf-form-field-option text="option1"/>
                <rx:pdf-form-field-option text="option2"/>
                <rx:pdf-form-field-option text="option3"/>
                <rx:pdf-form-field-option text="option4"/>
                <rx:pdf-form-field-option text="option5"/>
                <rx:pdf-form-field-option text="option6"/>
            </rx:pdf-form-field-combobox>
        </rx:pdf-form-field>
        <fo:block>
            <fo:leader/>
        </fo:block>
    </fo:block-container>
</xsl:template>
<xsl:template match="Textbox | Datebox">
    <fo:block margin-left="10pt" margin-right="10pt" keep-with-next.within-page="always">
        <xsl:value-of select="@Field"/>
    </fo:block>
    <fo:block-container margin-left="10pt" margin-right="10pt">
        <xsl:if test="@Size != ''">
            <xsl:attribute name="height">
                <xsl:value-of select="concat(@Size,'px')"/>
            </xsl:attribute>
        </xsl:if>
        <rx:pdf-form-field name="{@Field}">
            <rx:pdf-form-field-text border-width="1pt" border-style="solid"
                border-color="silver" color="blue" font-size="10pt">
                <xsl:if test="@Size != ''">
                    <xsl:attribute name="multiline">
                        <xsl:text>true</xsl:text>
                    </xsl:attribute>
                </xsl:if>
                <xsl:attribute name="text">
                    <xsl:value-of select="@Value"/>
                </xsl:attribute>
            </rx:pdf-form-field-text>
        </rx:pdf-form-field>
        <fo:block>
            <fo:leader/>
        </fo:block>
    </fo:block-container>
</xsl:template>
</xsl:stylesheet>

The result is a fillable form field (uses some information like the @ID attribute in the source as the name of the field, the @Value as the default value and for multiline fields, using the @Size as the height in pixels. 结果是一个可填写的表单字段(使用某些信息,例如源中的@ID属性作为字段名称,将@Value作为默认值,对于多行字段,使用@Size作为高度(以像素为单位)。

The result is shown below, you can see the highlighted fields. 结果如下所示,您可以看到突出显示的字段。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM