开发者

Put xml node's full path in attribute file and read the node's value from main xsl file in xsl fo

开发者 https://www.devze.com 2022-12-12 14:51 出处:网络
I have been using fop 0.95 to generate pdf files from xml data. I have three files involved in the process: test.xml, test.xsl and attributes.xsl. Naturally I have xml data in xml file. Here test.xml

I have been using fop 0.95 to generate pdf files from xml data. I have three files involved in the process: test.xml, test.xsl and attributes.xsl. Naturally I have xml data in xml file. Here test.xml is the main xsl file which imports attribute sets from attributes.xsl file. For e开发者_C百科xample, I have following entries in the attributes.xsl file:

<xsl:attribute-set name="headerTable" foa:class="table">
    <xsl:attribute name="table-layout">fixed</xsl:attribute>
    <xsl:attribute name="width">6.05in</xsl:attribute>
    <xsl:attribute name="text-align">left</xsl:attribute>
    <xsl:attribute name="white-space-collapse">false</xsl:attribute>
</xsl:attribute-set>

Now my requirement is to place the attribute name in attribute file and store the associated values in the xml file. This way:

<MyRoot>
   <tableHeader>
      <tableLayout>fixed</tableLayout>
      <width>6.05in</width>
      <textAlign>left</textAlign>
      <whiteSpaceCollapse>false</whiteSpaceCollapse>
   </tableHeader>
</MyRoot>

After this I will have the attribute file as follows:

<xsl:attribute-set name="headerTable" foa:class="table">
   <xsl:attribute name="table-layout">MyRoot/tableHeader/tableLayout</xsl:attribute>
   <xsl:attribute name="width">MyRoot/tableHeader/width</xsl:attribute>
   <xsl:attribute name="text-align">MyRoot/tableHeader/textAlign</xsl:attribute>
   <xsl:attribute name="white-space-collapse">MyRoot/tableHeader/whiteSpaceCollapse</xsl:attribute>
</xsl:attribute-set>

As usual I use the attribute from the main xsl file as follows:

<fo:table xsl:use-attribute-sets="headerTable">
   <fo:table-column column-width="3in"></fo:table-column>
   <fo:table-column column-width="3.5in"></fo:table-column>
   <fo:table-body>
      <!--table rows and cells goes here-->             
   </fo:table-body>
</fo:table>

While executing, I get the following error:

"Ignoring property: table-layout="MyRoot/tableHeader/tableLayout" <Illegal character; property:'table-layout'>"

Has anyone any idea on how to accomplish this? Thanks.


After wandering in various websites and getting no response in the question here, I had hard times with the problem. While thinking upon the problem and performing hit and trial, I just got to put this line:

<xsl:attribute name="width">
     <xsl:value-of select="MyRoot/tableHeader/width">
     </xsl:value-of>
</xsl:attribute>

instead of the following in the attribute file:

<xsl:attribute name="width">MyRoot/tableHeader/width</xsl:attribute>

And I did same for all those xml node path placed in the attribute file. This worked awsome! Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号