Quote:
quote:Originally posted by prashant.unleashed
Quote:
quote:Originally posted by mhkay
|
Quote:
>so I think there wontbe anyone to help me out
Probably not, unless you can supply the information that was requested.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
Hi Michael ,
sorry but its too big to put onto the forum, anyway here is that code which gives me that sort of exception..
can u please look into it...pls find below two stylesheets which have been used.. thnx waiting
public String getOutput(){
String msg="";
try{
DAODomino dao = null;
DominoAccessVO domAccessVO = null;
dao = new DAODomino();
domAccessVO = new DominoAccessVO();
domAccessVO.setCookie(cookies);
domAccessVO.setDominoURL( server+"/"+ffDbPath+"/formResultsXML?ReadForm&RestrictToCategory="+(Stri ng)collFillFormURL.get(0)+"&count=-1" );
String strResults =dao.getData(domAccessVO, requestSetting.getWebSphereSetting()).getDominoTxt ();
dao = new DAODomino();
domAccessVO = new DominoAccessVO();
domAccessVO.setCookie(cookies);
domAccessVO.setDominoURL( server+"/"+ffDbPath+"/viewDefinitionForms/"+(String)collFillFormURL.get(0)+"/$File/FormDef.xml" );
byte[] byteArrFormDef = dao.getData(domAccessVO,requestSetting.getWebSpher eSetting()).getDominoTxt().getBytes();
String strFormDefValues = new ParseXMLwithStylesheet().getResult(new ByteArrayInputStream(byteArrFormDef),
new ByteArrayInputStream( ResourceLoader.getResource( "ParseFormDefResults.xsl", requestSetting.getSiteSetting().getEncoding() ).getBytes())
);
int index = strResults.indexOf("<submission>");
strResults = strResults.substring(0,index) + strFormDefValues + strResults.substring(index);
/*
* Generate XSL for profile replace.
*/
msg = new ParseXMLwithStylesheet().getResult(
new ByteArrayInputStream(strResults.getBytes()),
new ByteArrayInputStream( ResourceLoader.getResource( "ParseResults.xsl", requestSetting.getSiteSetting().getEncoding() ).getBytes())
);
msg = new ParseXMLwithStylesheet().getResult(
new ByteArrayInputStream(msg.getBytes()), new ByteArrayInputStream( ResourceLoader.getResource( "Results2HTML.xsl", requestSetting.getSiteSetting().getEncoding() ).getBytes())
);
}catch(Exception e){
msg = "Exception: in FillFormService.getHTML(), msg: "+e.getLocalizedMessage();
log.error(msg, e);
}
return msg;
}
}
.........
ParseFormDefResults.xsl
<?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" cdata-section-elements="description" />
- <!--
This stylesheet generates xml of the form:
<FIELDS>
<FIELD pushmail="0" type="13" description="News" publicField="0">
<FIELDALIAS>TESTTESTTEST</FIELDALIAS>
<VALUES>
<VALUE category="News">Finance</VALUE>
<VALUE category="News">News</VALUE>
<VALUE category="Dette er en test">TESTTEST1</VALUE>
<VALUE category="Dette er en test">test2</VALUE>
<VALUE category="Dette er en test">TESTTEST3</VALUE>
<VALUE category="Dette er en test">test4</VALUE>
</VALUES>
</FIELD>
</FIELDS>
-->
- <xsl:template match="/">
- <submission>
- <FIELDS>
- <xsl:for-each select="//field[.//input[@type='radio' or @type='checkbox']]">
- <FIELD>
- <FIELDALIAS>
<xsl:value-of select="@alias" />
</FIELDALIAS>
- <description>
<xsl:value-of select="./description" />
</description>
- <VALUES>
- <xsl:for-each select=".//input">
- <xsl:if test="@value[.!='']">
- <VALUE>
<xsl:value-of select="@value" />
</VALUE>
</xsl:if>
</xsl:for-each>
</VALUES>
</FIELD>
</xsl:for-each>
</FIELDS>
</submission>
</xsl:template>
</xsl:stylesheet>
-----
ParseResults.xsl
<?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="yes" cdata-section-elements="description" />
- <xsl:template match="/">
- <fields>
- <xsl:for-each select="//submission[1]/FIELDS">
- <xsl:for-each select=".//FIELD">
- <field>
- <xsl:attribute name="alias">
<xsl:value-of select=".//FIELDALIAS" />
</xsl:attribute>
- <xsl:for-each select=".//VALUE">
- <xsl:call-template name="count">
<xsl:with-param name="value" select="." />
<xsl:with-param name="alias" select="ancestor::FIELD/FIELDALIAS" />
</xsl:call-template>
</xsl:for-each>
- <description>
<xsl:value-of select="./description" />
</description>
</field>
</xsl:for-each>
</xsl:for-each>
</fields>
</xsl:template>
- <xsl:template name="count">
<xsl:param name="value" />
<xsl:param name="alias" />
- <value>
- <xsl:attribute name="name">
<xsl:value-of select="." />
</xsl:attribute>
- <!--
The -1 at the end compensates for the extra field inserted so it is possible to see values and
or fields that has not been submitted
-->
- <xsl:attribute name="count">
<xsl:value-of select="count(//FIELDS[FIELD[FIELDALIAS[.=$alias]]//VALUE[.=$value]])-1" />
</xsl:attribute>
</value>
</xsl:template>
</xsl:stylesheet>
|
hi here is one more XSL ..sorry i was missed..
Results2HTML.xsl
<?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="html" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" />
- <!--
This stylesheet parses xml of the form:
<fields>
<field alias="">
<value name="Finance" count="1" />
<value name="News" count="1" />
<value name="TESTTEST1" count="1" />
<value name="test2" count="1" />
<value name="TESTTEST3" count="1" />
<value name="test4" count="1" />
</field>
<field alias="">
<value name="Finance" count="5" />
<value name="News" count="5" />
<value name="test1" count="5" />
<value name="test2" count="5" />
<value name="test3" count="5" />
<value name="test5" count="1" />
<value name="test4" count="4" />
</field>
-->
- <xsl:template match="/">
- <table class="FFQuickPollResultsTable">
- <xsl:for-each select="//field">
- <tr>
- <td colspan="4" class="FFQuickPollResultsTableFieldDescriptionRow" >
<xsl:value-of select="./description" />
</td>
</tr>
- <xsl:call-template name="genline">
- <xsl:with-param name="countall">
<xsl:value-of select="sum(./value/@count)" />
</xsl:with-param>
- <xsl:with-param name="max">
- <!-- Find the max number for reference for the bars
-->
- <xsl:for-each select="./value">
<xsl:sort select="@count" data-type="number" order="descending" />
- <xsl:if test="position() = 1">
<xsl:value-of select="number(@count)" />
</xsl:if>
</xsl:for-each>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</table>
</xsl:template>
- <xsl:template name="genline">
<xsl:param name="countall" />
<xsl:param name="max" />
- <xsl:for-each select="value">
- <tr>
- <!-- Print the title
-->
- <td class="FFQuickPollResultsTableColl1">
<xsl:value-of select="@name" />
</td>
- <!-- Print the count
-->
- <td class="FFQuickPollResultsTableColl2">
<xsl:value-of select="@count" />
<xsl:text>of</xsl:text>
<xsl:value-of select="$countall" />
</td>
- <!-- Print the bar representing the percent
-->
- <td class="FFQuickPollResultsTableColl3">
- <span class="FFQuickPollResultsBar">
- <xsl:attribute name="style">
<xsl:text>width:</xsl:text>
- <xsl:if test="$countall!=0">
<xsl:value-of select="((@count div $countall) div ($max div $countall)) * 100" />
</xsl:if>
- <xsl:if test="$countall=0">
<xsl:text>0</xsl:text>
</xsl:if>
<xsl:text>%</xsl:text>
</xsl:attribute>
</span>
</td>
- <!-- Print the percentage nr.
-->
- <td class="FFQuickPollResultsTableColl4">
- <xsl:if test="$countall!=0">
<xsl:value-of select="round((@count div $countall) * 100)" />
</xsl:if>
- <xsl:if test="$countall=0">
<xsl:text>0</xsl:text>
</xsl:if>
<xsl:text>%</xsl:text>
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>