[英]How do I transform nested tabcontrol elements in XML/XSLT to XSL-FO
我有一個使用tabcontrols和tabpages的動態xml記錄,我需要創建xsl-fo。 但是,我找不到在線參考解決方案。 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>
在您呈現的源XML中,或者試圖理解輸出的期望“外觀”時,並沒有提供太多信息。
PDF Acroform字段在具有適當許可證的RenderX XEP中受支持,並確保您添加了rx:Extension命名空間。 我只是使用下面的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>
結果是一個可填寫的表單字段(使用某些信息,例如源中的@ID屬性作為字段名稱,將@Value作為默認值,對於多行字段,使用@Size作為高度(以像素為單位)。
結果如下所示,您可以看到突出顯示的字段。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.