p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: XSLT Programmer's Reference, 2nd Edition (http://p2p.wrox.com/forumdisplay.php?f=52)
-   -   XSLT related exception (http://p2p.wrox.com/showthread.php?t=57398)

prashant.unleashed May 3rd, 2007 04:32 AM

XSLT related exception
 
Hi friends,
This is a sincere request to all of you guys..I need help
First time When I login into a page,it is succeded, after that i changed the url to the previous one and try to login once again , but this time i am geting exception like
-------
Exception: in FillFormService.getHTML(), msg: TransformerConfigurationException: ParseXMLwithStylesheet.run(), msg: javax.xml.transform.TransformerConfigurationExcept ion: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Expected ], but found: Assistans
------------
Can anyone please help me out from this problem?
thnx..




mhkay May 3rd, 2007 07:04 AM

I think it's telling you there's a syntax error in your stylesheet. Without seeing the stylesheet I can't help you further. But also, there will be some more specific error messages somewhere, you need to find out where!

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

prashant.unleashed May 3rd, 2007 07:28 AM

Hi ,
but when there is syntax error in XSL, then at the very first it wont have to work. look when I login to the page first time, it gets login.but when i press back button on browser, i get the exception..there is no logout option.
Quote:

quote:Originally posted by mhkay
 I think it's telling you there's a syntax error in your stylesheet. Without seeing the stylesheet I can't help you further. But also, there will be some more specific error messages somewhere, you need to find out where!

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

mhkay May 3rd, 2007 10:09 AM

Sorry, without knowing anything about your system or seeing any code it's quite impossible to debug this.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

prashant.unleashed May 7th, 2007 04:52 AM

Quote:

quote:Originally posted by mhkay
 Sorry, without knowing anything about your system or seeing any code it's quite impossible to debug this.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Hi Michael,
please go through this code..this is the XSL..pls see if any error is there..

  <?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="script" />
- <xsl:template match="*|@*|text()|comment()">
- <xsl:copy>
  <xsl:apply-templates select="*|@*|text()|comment()" />
  </xsl:copy>
  </xsl:template>
- <!-- Matches the person tag containing all information about the logged in user.
        First all notes fields are parsed in a for loop, next all the dynamic userdefined
        fields are parsed.

  -->
- <xsl:template match="person" xmlns:coloplastFunctions="xalan://com.coloplast.web.fillform2.classes.resources.Pars eXMLwithStylesheet">
- <xsl:for-each select="./*[@fieldref!='']">
- <!-- Match input elements
  -->
- <xsl:call-template name="create_text_input">
- <xsl:with-param name="match">
  field[starts-with(@notestype,'
  <xsl:value-of select="@fieldref" />
  ')]
  </xsl:with-param>
  <xsl:with-param name="value" select="." />
  </xsl:call-template>
- <!-- Match textarea elements
  -->
- <xsl:call-template name="create_textarea">
- <xsl:with-param name="match">
  field[starts-with(@notestype,'
  <xsl:value-of select="@fieldref" />
  ')]
  </xsl:with-param>
  <xsl:with-param name="value" select="." />
  </xsl:call-template>
- <!-- Match choice elements
  -->
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
  field[starts-with(@notestype,'
  <xsl:value-of select="@fieldref" />
  ')]/input[@value='
  <xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
  ']
  </xsl:with-param>
  <xsl:with-param name="attributename">checked</xsl:with-param>
  </xsl:call-template>
- <!-- Match select elements
  -->
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
  field[starts-with(@notestype,'
  <xsl:value-of select="@fieldref" />
  ')]/select/option[@value='
  <xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
  ']
  </xsl:with-param>
  <xsl:with-param name="attributename">selected</xsl:with-param>
  </xsl:call-template>
- <!-- Static fields SET PROFILE ENTRY TRUE
  -->
- <xsl:call-template name="create_profile_attribute">
- <xsl:with-param name="match">
  field[starts-with(@notestype,'
  <xsl:value-of select="@fieldref" />
  ')]
  </xsl:with-param>
  </xsl:call-template>
  </xsl:for-each>
- <!-- Dynamic TEXT fields
  -->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Textfield' or @type='password']">
- <xsl:call-template name="create_text_input">
- <xsl:with-param name="match">
  subform[@alias='
  <xsl:value-of select="ancestor::FORM/FORMALIAS/." />
  ']/field[@alias='
  <xsl:value-of select="./FIELDALIAS/." />
  ']
  </xsl:with-param>
  <xsl:with-param name="value" select="./VALUES/VALUE/." />
  </xsl:call-template>
  </xsl:for-each>
- <!-- Dynamic TEXTAREA fields
  -->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Textarea']">
- <xsl:call-template name="create_textarea">
- <xsl:with-param name="match">
  subform[@alias='
  <xsl:value-of select="ancestor::FORM/FORMALIAS/." />
  ']/field[@alias='
  <xsl:value-of select="./FIELDALIAS/." />
  ']
  </xsl:with-param>
  <xsl:with-param name="value" select="./VALUES/VALUE/." />
  </xsl:call-template>
  </xsl:for-each>
- <!-- Dynamic RADIO & CHECKBOX fields
  -->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Radiobutton' or @type='Checkbox' or @type='ExpandingCategories']/VALUES/VALUE">
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
  subform[@alias='
  <xsl:value-of select="ancestor::FORM/FORMALIAS/." />
  ']/field[@alias='
  <xsl:value-of select="../../FIELDALIAS/." />
  ']/input[@value='
  <xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
  ']
  </xsl:with-param>
  <xsl:with-param name="attributename">checked</xsl:with-param>
  </xsl:call-template>
  </xsl:for-each>
- <!-- Dynamic EXPANDING CATEGORIES fields
  -->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='ExpandingCategories']/VALUES/VALUE">
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
  subform[@alias='
  <xsl:value-of select="ancestor::FORM/FORMALIAS/." />
  ']/field[@alias='
  <xsl:value-of select="../../FIELDALIAS/." />
  ']//category[value='
  <xsl:value-of select="@category" />
  ']//input[@value='
  <xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
  ']
  </xsl:with-param>
  <xsl:with-param name="attributename">checked</xsl:with-param>
  </xsl:call-template>
  </xsl:for-each>
- <!-- Dynamic SELECT & SELECTMULTI fields
  -->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Select' or @type='Selectmulti']/VALUES/VALUE">
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
  subform[@alias='
  <xsl:value-of select="ancestor::FORM/FORMALIAS/." />
  ']/field[@alias='
  <xsl:value-of select="../../FIELDALIAS/." />
  ']/select/option[@value='
  <xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
  ']
  </xsl:with-param>
  <xsl:with-param name="attributename">selected</xsl:with-param>
  </xsl:call-template>
  </xsl:for-each>
- <!-- Dynamic fields SET PROFILE ENTRY TRUE
  -->
- <xsl:for-each select="./FORM/FIELDS/FIELD">
- <xsl:call-template name="create_profile_attribute">
- <xsl:with-param name="match">
  subform[@alias='
  <xsl:value-of select="ancestor::FORM/FORMALIAS/." />
  ']/field[@alias='
  <xsl:value-of select="./FIELDALIAS/." />
  ']
  </xsl:with-param>
  </xsl:call-template>
  </xsl:for-each>
  </xsl:template>
- <!-- Template for inserting xsl that changes the value-attribute of input fields.
        This template takes two arguments:
        1. match: the x-path expression that locates the input field where the value should
            be inserted
        2. value: the value to insert.

  -->
- <xsl:template name="create_profile_attribute">
  <xsl:param name="match" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
  <xsl:value-of select="$match" />
  </xsl:attribute>
- <xsl:element name="xsl:copy">
- <xsl:element name="xsl:apply-templates">
  <xsl:attribute name="select">@*</xsl:attribute>
  </xsl:element>
- <xsl:element name="xsl:attribute">
  <xsl:attribute name="name">in_profile_registration</xsl:attribute>
  <xsl:text>true</xsl:text>
  </xsl:element>
- <xsl:element name="xsl:apply-templates">
  <xsl:attribute name="select">@*|*|text()</xsl:attribute>
  </xsl:element>
  </xsl:element>
  </xsl:element>
  </xsl:template>
- <!-- Template for inserting xsl that changes the value-attribute of input fields.
        This template takes two arguments:
        1. match: the x-path expression that locates the input field where the value should
            be inserted
        2. value: the value to insert.

  -->
- <xsl:template name="create_text_input">
  <xsl:param name="match" />
  <xsl:param name="value" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
  <xsl:value-of select="$match" />
  /input[@type='text' or @type='password']/@value
  </xsl:attribute>
- <xsl:element name="xsl:attribute">
  <xsl:attribute name="name">value</xsl:attribute>
  <xsl:value-of select="$value" />
  </xsl:element>
  </xsl:element>
  </xsl:template>
- <!-- Template for inserting xsl that changes the content of textarea tags.
        This template takes two arguments:
        1. match: the x-path expression that locates the field where the textarea content should
            be inserted
        2. value: the value to insert.

  -->
- <xsl:template name="create_textarea">
  <xsl:param name="match" />
  <xsl:param name="value" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
  <xsl:value-of select="$match" />
  /textarea
  </xsl:attribute>
- <xsl:element name="xsl:copy">
- <xsl:element name="xsl:apply-templates">
  <xsl:attribute name="select">@*</xsl:attribute>
  </xsl:element>
  <xsl:value-of select="$value" />
  </xsl:element>
- <!-- <xsl:element name="xsl:attribute">
                <xsl:attribute name="name">profile</xsl:attribute>
                <xsl:text>true</xsl:text>
            </xsl:element>
  -->
  </xsl:element>
  </xsl:template>
- <!-- Template for inserting xsl that changes the value-attribute of 'choice' fields.
        This template takes two arguments:
        1. match: the x-path expression that locates the input field where the value should
            be inserted
        2. attributename: the 'selected' attribute that indicates the choice has beed seelcted
            in Checkbox and Radio button elements it is: 'checked', and in Select and Select Multi
            it is: 'selected'.

  -->
- <xsl:template name="create_choice_input">
  <xsl:param name="match" />
  <xsl:param name="attributename" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
  <xsl:value-of select="$match" />
  </xsl:attribute>
- <xsl:element name="xsl:copy">
- <xsl:element name="xsl:apply-templates">
  <xsl:attribute name="select">@*</xsl:attribute>
  </xsl:element>
- <xsl:element name="xsl:attribute">
- <xsl:attribute name="name">
  <xsl:value-of select="$attributename" />
  </xsl:attribute>
  <xsl:value-of select="$attributename" />
  </xsl:element>
- <xsl:element name="xsl:apply-templates">
  <xsl:attribute name="select">@*|*|text()</xsl:attribute>
  </xsl:element>
  </xsl:element>
  </xsl:element>
  </xsl:template>
  </xsl:stylesheet>



mhkay May 7th, 2007 05:32 AM

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

prashant.unleashed May 7th, 2007 06:52 AM

no , but atleast some one has the view,sometimes it doesnt need to see the code..if there is any error in XSL , then the first time it logs in, it shud have reported error..in our case there are lot of XSLs so one cannt guess what is wrong besides us..if i get the root of the error then i can fix it..



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

prashant.unleashed May 11th, 2007 07:19 AM


so I think there wontbe anyone to help me out!!!!!!




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

mhkay May 11th, 2007 08:25 AM

>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

prashant.unleashed May 14th, 2007 05:55 AM

Quote:

quote:Originally posted by mhkay
 >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>





All times are GMT -4. The time now is 08:00 PM.

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