3 Replies Latest reply: Oct 22, 2013 3:23 PM by user4531996 RSS

    xslt graph in a rtf template. Can an external variable be used inside the graph definition?

    user4531996

      I'm working with BI Publisher 10g, building an rtf template that would display a table and a graph by iterating on one of the xml tags from the input file.

      I got the table working using am xslt variable set when the xml tag associated value changes (DATAGROUPID).

       

       

      <?for-each:(/DATA/SITE/SITE_DATA)?> <?sort:DATAGROUPID;'ascending';data-type='number'?>

      <?xdoxslt:set_variable($_XDOCTX,'SITE',DATAGROUPID)?>

      <?for-each:(/DATA//DIMS/LOCALES[LOCALE = 'en']/TEXT)?><?sort:DIMNAME;'ascending';data-type='text'?>

      <?xdoxslt:set_variable($_XDOCTX,'DIMID',DIMID)?>

      <?round(/DATA/SITE/SITE_DATA[DATAGROUPID = xdoxslt:get_variable($_XDOCTX,'SITE')]/YEAR[SURVEYYEAR = 2012]/DIM[DIMID = xdoxslt:get_variable($_XDOCTX,'DIMID')]/ITEM[ITEMID = 0]/PFAV)?>

      <?end for-each?>

       

      chart:

      <Graph seriesEffect="SE_AUTO_GRADIENT" graphType="BAR_VERT_PERCENT" autoLayout="AL_AS_NEEDED">

      <LegendArea visible="true" automaticPlacement="AP_NEVER" position="LAP_BOTTOM"/>

      <SeriesItems>

      <Series id="0" color="#FF0000"/>

      <Series id="1" color="#FFFF00"/>

      <Series id="2" color="#00FF00"/>

      </SeriesItems>

      <MarkerText visible="true" markerTextPlace="MTP_CENTER">

      <GraphFont name="Arial" size="20" bold="true" italic="false" underline="false"/>

      <Y1ViewFormat>

      <ViewFormat decimalDigit="0" decimalSeparatorUsed="true" decimalDigitUsed="true"/>

      </Y1ViewFormat>

      </MarkerText>

      <LegendText>

      <GraphFont name="Arial" size="20" bold="false" italic="false" underline="false"/>

      </LegendText>

      <Y1TickLabel>

      <GraphFont name="Arial" size="12" bold="false" italic="false" underline="false"/>

      </Y1TickLabel>

      <O1TickLabel wordWrapEnabled="false" tickLabelStaggered="false">

      <GraphFont name="Arial" size="20" bold="true" italic="false" underline="false"/>

      </O1TickLabel>

      <LocalGridData colCount="{count(xdoxslt:group(/DATA/SITE/SITE_DATA/YEAR[SURVEYYEAR = 2012]/DIM, 'DIMID'))}" rowCount="3">

      <RowLabels>

      <Label>Unfavorable        </Label>

      <Label>Neutral</Label>

      <Label>Favorable</Label>

      </RowLabels>

      <ColLabels>

      <xsl:for-each select="/DATA/DIMS/LOCALES[LOCALE = 'en']/TEXT">

      <xsl:sort select="DIMNAME"/>

      <Label>

      <xsl:value-of select="DIMNAME"/>

      </Label>

      </xsl:for-each>

      </ColLabels>

      <DataValues>

      <RowData>

      <xsl:for-each select="/DATA/DIMS/LOCALES[LOCALE = 'en']/TEXT">

      <xsl:sort select="DIMNAME"/>

      <Cell>

      <xsl:variable name="DIMID" select="DIMID"/>

      <xsl:value-of select="/DATA/SITE/SITE_DATA/YEAR[SURVEYYEAR = 2012]/DIM[DIMID = $DIMID]/ITEM[ITEMID = 0 and PUNFAV != 0]/PUNFAV"/>

      </Cell>

      </xsl:for-each>

      </RowData>

      <RowData>

      <xsl:for-each select="/DATA/DIMS/LOCALES[LOCALE = 'en']/TEXT">

      <xsl:sort select="DIMNAME"/>

      <Cell>

      <xsl:variable name="DIMID" select="DIMID"/>

      <xsl:value-of select="/DATA/SITE/SITE_DATA/YEAR[SURVEYYEAR = 2012]/DIM[DIMID = $DIMID]/ITEM[ITEMID = 0 and PNEU != 0]/PNEU"/>

      </Cell>

      </xsl:for-each>

      </RowData>

      <RowData>

      <xsl:for-each select="/DATA/DIMS/LOCALES[LOCALE = 'en']/TEXT">

      <xsl:sort select="DIMNAME"/>

      <Cell>

      <xsl:variable name="DIMID" select="DIMID"/>

      <xsl:value-of select="/DATA/SITE/SITE_DATA/YEAR[SURVEYYEAR = 2012]/DIM[DIMID = $DIMID]/ITEM[ITEMID = 0 and PFAV !=0]/PFAV"/>

      </Cell>

      </xsl:for-each>

      </RowData>

      </DataValues>

      </LocalGridData>

      </Graph>

      <?end for-each?>

       

      So, on the table this line gets the correct variable from the input file:

      <?round(/DATA/SITE/SITE_DATA[DATAGROUPID = xdoxslt:get_variable($_XDOCTX,'SITE')]/YEAR[SURVEYYEAR = 2012]/DIM[DIMID = xdoxslt:get_variable($_XDOCTX,'DIMID')]/ITEM[ITEMID = 0]/PFAV)?>

       

      How can I replicate that logic inside the table definition?

      <xsl:value-of select="/DATA/SITE/SITE_DATA/YEAR[SURVEYYEAR = 2012]/DIM[DIMID = $DIMID]/ITEM[ITEMID = 0 and PFAV !=0]/PFAV"/>

       

      Input data looks like this:

      <DATA>

      - <SITE>

      - <SITE_DATA>

       

       

      <DATAGROUPID>1032817</DATAGROUPID>

       

       

      <DATAGROUPNAME>My Sales</DATAGROUPNAME>

       

       

      - <YEAR>

       

       

      <SURVEYYEAR>2012</SURVEYYEAR>

       

       

      - <DIM>

       

       

      <DIMID>1</DIMID>

       

       

      - <ITEM>

       

       

      <ITEMID>0</ITEMID>

       

       

      <PFAV>88</PFAV>

       

       

      <PNEU>13</PNEU>

       

       

      <PUNFAV>0</PUNFAV>
      ...

       

      - <ITEM>

       

       

      <ITEMID>40</ITEMID>

       

       

      <PFAV>100</PFAV>

       

       

      <PNEU>0</PNEU>

       

       

      <PUNFAV>0</PUNFAV>

       

      </ITEM>

      </DIM>

      </YEAR>

      </SITE_DATA>

       

      - <SITE_DATA>

       

       

      <DATAGROUPID>1032816</DATAGROUPID>

       

       

      <DATAGROUPNAME>Your Sales</DATAGROUPNAME>

       

       

      - <YEAR>

       

       

      <SURVEYYEAR>2012</SURVEYYEAR>

       

       

      - <DIM>

       

       

      <DIMID>1</DIMID>

       

       

      - <ITEM>

       

       

      <ITEMID>0</ITEMID>

       

       

      <PFAV>71</PFAV>

       

       

      <PNEU>25</PNEU>

       

       

      <PUNFAV>4</PUNFAV>

       

      .....

       

      I can include a complete sample on request, I thought this would be enough to illustrate the issue.

      I'll appreciate any help you can provide.