2016-09-27 34 views
-1

我有一個使用tabcontrols和tabpages的動態xml記錄,我需要創建xsl-fo。但是,我找不到任何對在線解決方案的參考。從XML摘錄如下:如何將XML/XSLT中的嵌套tabcontrol元素轉換爲XSL-FO

<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> 

+1

請提出具體問題。 –

+1

你想要一個頁面上的數據,或者你想在PDF中可填寫的表單元素作爲結果? –

+1

我需要一個頁面上的數據以及可填充的表單元素(其中elemnent值尚未完成)以與呈現的xml類似的格式。基本上,我希望用戶能夠打印出調查問卷,幷包括已經記錄的任何響應。 –

回答

2

沒有很多在你的源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作爲高度(以像素爲單位)

結果如下所示,您可以看到突出顯示的字段。

enter image description here

相關問題