-1

I have xml file in which having some css properties and I want to apply on table

XML file is as follows :-

   <code>
     <reportConfiguration>
        <details_background_color>white</details_background_color>  
        <page_header_horizontal_align>center</page_header_horizontal_align>
        <page_header_font_size>12pt</page_header_font_size>
     </reportConfiguration>
   </code>

I want use details_background_color , details_bold to apply value in table , code as follows but not working

<code>
  <fo:block>
        <xsl:for-each select="element_1">
         <fo:block  font-size="document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_font_size" font-weight="document('xmlFile_reportConfig.xml')/reportConfiguration/details_bold" text-align="document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_horizontal_align"  vertical-align="middle">
                            select="document('file:///D:/DATA/Marquee/dial_stats_UK.xml')/UK_Products_Pipeline/LastFinishCode"
                                <xsl:value-of select="."/>
                            </fo:block>
                        </xsl:for-each>
                    </fo:block>
</code>
Mathias Müller
  • 22,203
  • 13
  • 58
  • 75
Nilesh Patil
  • 35
  • 1
  • 6
  • There's too much we don't see. Specifically, you refer to `element_1` elements which do not appear in the input XML you have shown. In the text, you mention `details_bold`, where is it? Also, please show more XSLT code (the whole template, or the full stylesheet). – Mathias Müller Aug 25 '14 at 11:38

1 Answers1

0

I am assuming the XML file you have shown us is not the primary document you are applying the XSLT too, but a secondary document you need to reference in addition to the main one, otherwise there would be no need in using the document function.

(I am also going to assume the <code> tags showing in your question should also not be there).

Anyway, this is how you are currently trying to reference the external document

<fo:block 
    font-size="document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_font_size"

When you try to set the value of an attribute using an expression, you need to use Attribute Value Templates, otherwise the value of the attribute will be literally what you write. In other words, you need to enclose the expression in curly braces to indicate it is an expression to be evaluated:

<fo:block 
    font-size="{document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_font_size}"

It might be slightly easier to hold a reference to the document in a variable though, if you need to access multiple values from it. For example:

<xsl:variable name="config" select="document('xmlFile_reportConfig.xml')/reportConfiguration" />
<fo:block font-size="{$config/page_header_font_size}" font-weight="{$config/details_bold}" />

Note, this does assume your report configuration XML is in the same directory as the XSLT file.

Tim C
  • 70,053
  • 14
  • 74
  • 93