|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Getting error message - Open quote is expected for Choose statementI am sorry to have to bother you, but I am sort of at a stand still and have been trying to find some info that will explain how to do this but haven't had any luck yet.
I am creating an xml file from a Notes document. The xml file uses .xsl file for the creation of the pdf. The format for the Purchase Order may have one item on the table, or 15 items within the table. Due to the manner in which the notes document was built, the xml file has the values for each of the items in separate elements. So I am needing to read all of the elements in the xml file realizing that some of the elements may be empty. For the empty elments, I do not want to display anything in the table so that is why I am thinking about the use of the "Choose" statment. Below is an excerpt of the code that I have, this is the error statement in the Java debugger: Open quote is expected for attribute "holdnum" associated with an element type "xsl:when". Sorry for being so long in explaining this but I hope you can decipher what I am wanting to do. Thank you in advance for any comments. jlr CODE: <!--Terms and Account Information Section--> <fo:block text-align="left"> <fo:table table-layout="fixed" xsl:use-attribute-sets="newborderspace" border-collapse="collapse" empty-cells="hide"> <fo:table-column column-width="43mm"/> <fo:table-column column-width="44mm"/> <fo:table-column column-width="44mm"/> <fo:table-column column-width="44mm"/> <fo:table-body> <!--Adding first row in table--> <fo:table-row border-after-style="double"> <fo:table-cell xsl:use-attribute-sets="cell-padding" border="solid black 0.5px"> <fo:block xsl:use-attribute-sets="detailtable"> <xsl:value-of select="TermsSection/TermsTitle"/> </fo:block> <fo:block xsl:use-attribute-sets="lgdetailtable"> <xsl:value-of select="TermsSection/Terms"/> </fo:block> </fo:table-cell> </fo:table-row> <!--At this point want to check the value of the holdnum variable if the value is equal to 1, than do this part otherwise go on down to the next when statement and check if it matches, if it does, execute, else go to the next statement.--> <xsl:variable name= "holdnum" select="numitemtotal" /> <xsl:choose> <xsl:when holdnum = '1' > <fo:table-row <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block > <xsl:value-of select="header/column9"/> </fo:block> </fo:table-cell> <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block > <xsl:value-of select="header/column10"/> </fo:block> </fo:table-cell> </fo:table-row> </xsl:when> <xsl:when holdnum = '2' > <fo:table-row <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block > <xsl:value-of select="header/column19"/> </fo:block> </fo:table-cell> <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block > <xsl:value-of select="header/column20"/> </fo:block> </fo:table-cell> </fo:table-row> </xsl:when> <xsl:otherwise> <fo:table-row > <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block > <xsl:value-of select="header/column39"/> </fo:block> </fo:table-cell> <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block> <xsl:value-of select="header/column40"/> </fo:block> </fo:table-cell> </fo:table-row> </xsl:otherwise> </xsl:choose> </fo:table-body> </fo:table> </fo:block> <!--End of Terms and Account Information Section--> |
|
|
Re: Getting error message - Open quote is expected for Choose statementOn Fri, May 02 2008 14:55:45 +0100, jean.stachler@... wrote: ... > Below is an excerpt of the code that I have, this is the error statement in > the Java debugger: > > Open quote is expected for attribute "holdnum" associated with an element > type "xsl:when". ... > <!--At this point want to check the value of the holdnum > variable > if the value is equal to 1, than do this part otherwise go on > down > to the next when statement and check if it matches, if it > does, execute, > else go to the next statement.--> > > <xsl:variable name= "holdnum" select="numitemtotal" /> > <xsl:choose> > <xsl:when holdnum = '1' > <xsl:when test="$holdnum = 1"> where: - The 'test' attribute has the XPath expression to be evaluated. - The '$' is required for the variable reference. - Quoting the '1' isn't strictly necessary since it can be evaluated as a number. Evaluating it as a string as you have done may be infinitesimally faster since it would save doing two conversions. - You could just as easily do "numitemtotal = 1" - There are almost certainly ways of doing what you want without state variables and without repeating so much FO markup. For example (untested): <xsl:variable name="cell1"> <xsl:choose> <xsl:when test="numitemtotal = 1"> <xsl:value-of select="header/column9"/> </xsl:when> <xsl:when test="numitemtotal = 2"> <xsl:value-of select="header/column19"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="header/column39"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="cell2"> <xsl:choose> <xsl:when test="numitemtotal = 1"> <xsl:value-of select="header/column10"/> </xsl:when> <xsl:when test="numitemtotal = 2"> <xsl:value-of select="header/column20"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="header/column40"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <fo:table-row > <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block > <xsl:value-of select="$cell1"/> </fo:block> </fo:table-cell> <fo:table-cell border="solid black 0.5px" empty-cells="hide"> <fo:block> <xsl:value-of select="$cell2"/> </fo:block> </fo:table-cell> </fo:table-row> Regards, Tony Graham Tony.Graham@... Director W3C XSL FO SG Invited Expert Menteith Consulting Ltd XML, XSL and XSLT consulting, programming and training Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland Registered in Ireland - No. 428599 http://www.menteithconsulting.com -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- xmlroff XSL Formatter http://xmlroff.org xslide Emacs mode http://www.menteith.com/wiki/xslide Unicode: A Primer urn:isbn:0-7645-4625-2 |
| Free embeddable forum powered by Nabble | Forum Help |