Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: XSLT Programmer's Reference, 2nd Edition
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: XSLT Programmer's Reference, 2nd Edition
This is the forum to discuss the Wrox book XSLT: Programmer's Reference, 2nd Edition by Michael Kay; ISBN: 9780764543814
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: XSLT Programmer's Reference, 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old May 14th, 2007, 06:34 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>



  #12 (permalink)  
Old May 14th, 2007, 06:45 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

Sorry, this is looking way too complicated for a free advice service to handle. You either need to simplify the problem drastically, or you need to get a consultant in to help.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #13 (permalink)  
Old May 15th, 2007, 07:46 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mhkay
 Sorry, this is looking way too complicated for a free advice service to handle. You either need to simplify the problem drastically, or you need to get a consultant in to help.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #14 (permalink)  
Old May 15th, 2007, 07:48 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mhkay
 Sorry, this is looking way too complicated for a free advice service to handle. You either need to simplify the problem drastically, or you need to get a consultant in to help.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
ok Michael..thnx for the advice..I will solve it myself, dont need any consultant!!!

  #15 (permalink)  
Old May 24th, 2007, 06:50 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by prashant.unleashed
 
Quote:
quote:Originally posted by mhkay
Quote:
 Sorry, this is looking way too complicated for a free advice service to handle. You either need to simplify the problem drastically, or you need to get a consultant in to help.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
hi Michael,
sorry to disturb u once again..actually i was working on the other issues meanwhile i had solve the same problem on development server but i m still getting problem on (realtime) webserver..any idea !! pls advice me..

ok Michael..thnx for the advice..I will solve it myself, dont need any consultant!!!

  #16 (permalink)  
Old June 7th, 2007, 04:30 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mhkay
 Your stylesheet is generating a stylesheet, and I would guess that it's generating an invalid stylesheet. I can't actually run your code because it's using Java extension functions (probably quite unnecessarily). If you can post the generated XSLT code, that might give a better clue.

(Frankly, seeing this code I'm pretty amazed by your original post. Did you seriously expect anyone to be able to find the cause of your problem with so little information?)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Hi Michael,
   Really very sorry if my words had disturbed you but I was very angery as was getting very frustrated with this problem. I apologise for the same ..
    Leave it please..any way ,how are you? Actually I had solved it on development server and testing server but when it concerns with real time web server, i got the same exception!! ;-( please help me out ..

Thnaks
Prashant..

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception Handling in XSLT aintvoguish XSLT 2 January 8th, 2008 05:34 PM
XSLT related exception prashant.unleashed J2EE 0 May 3rd, 2007 04:44 AM
problem related to XSLT prashant.unleashed BOOK: Expert One-on-One J2EE Design and Development 0 May 3rd, 2007 03:42 AM
Exception when transforming using XSLT ksskumar XSLT 5 October 10th, 2006 06:20 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM



All times are GMT -4. The time now is 06:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.