RussellB Posted March 13, 2005 Author Posted March 13, 2005 Can anyone help? I want to use XSLT to perform a "find" request followed by a "new" request (conditional upon the find request returning zero records - error 401) all via one button click by the user. The user will submit about 10 fields but I only want to perform the find on one of those fields. If the find request returns zero records then I want to create a new record using all 10 of the fields originally submitted. Hope that makes sense!
RussellB Posted March 13, 2005 Posted March 13, 2005 Can anyone help? I want to use XSLT to perform a "find" request followed by a "new" request (conditional upon the find request returning zero records - error 401) all via one button click by the user. The user will submit about 10 fields but I only want to perform the find on one of those fields. If the find request returns zero records then I want to create a new record using all 10 of the fields originally submitted. Hope that makes sense!
RussellB Posted March 13, 2005 Author Posted March 13, 2005 Can anyone help? I want to use XSLT to perform a "find" request followed by a "new" request (conditional upon the find request returning zero records - error 401) all via one button click by the user. The user will submit about 10 fields but I only want to perform the find on one of those fields. If the find request returns zero records then I want to create a new record using all 10 of the fields originally submitted. Hope that makes sense!
Martin Brändle Posted March 14, 2005 Posted March 14, 2005 See the attached example file. The xsl files are commented, the example database not . The general ideas are as follows: - pass the non-searchable fields as tokens (it's not possible to pass them as fields directly and omit them on the layout as well. One would get a 102 error) - depending on the error code, show the found records or extract the values of the query (variable $request-query), then go on - either by using fmxslt:set_status_code(302) and fmxslt:set_header('Location','target_url') - or staying within the result page and using document('target_url') - target_url is the URL with the -new request Martin P.S. And here my question ...
Martin Brändle Posted March 14, 2005 Posted March 14, 2005 See the attached example file. The xsl files are commented, the example database not . The general ideas are as follows: - pass the non-searchable fields as tokens (it's not possible to pass them as fields directly and omit them on the layout as well. One would get a 102 error) - depending on the error code, show the found records or extract the values of the query (variable $request-query), then go on - either by using fmxslt:set_status_code(302) and fmxslt:set_header('Location','target_url') - or staying within the result page and using document('target_url') - target_url is the URL with the -new request Martin P.S. And here my question ...
Martin Brändle Posted March 14, 2005 Posted March 14, 2005 See the attached example file. The xsl files are commented, the example database not . The general ideas are as follows: - pass the non-searchable fields as tokens (it's not possible to pass them as fields directly and omit them on the layout as well. One would get a 102 error) - depending on the error code, show the found records or extract the values of the query (variable $request-query), then go on - either by using fmxslt:set_status_code(302) and fmxslt:set_header('Location','target_url') - or staying within the result page and using document('target_url') - target_url is the URL with the -new request Martin P.S. And here my question ... test_multipleactions.zip
ddhull Posted March 15, 2005 Posted March 15, 2005 Hi Martin, I was trying your test files out. I placed test_multipleactions.fp7 in library/filemaker server 7/data/databases/martin/ and placed the 3 multiple.xsl files in library/filemaker server 7/web publishing/xslt-template-files/martin/ but when I try http://myhost/fmi/xsl/martin/multiple.xsl I get "The requested file could not be found (file-er0001)" but I can put my own .xsl file in this same location and it will find my file. Am I missing something here? This stuff is driving me crazy er. Thanks, Doug
ddhull Posted March 15, 2005 Posted March 15, 2005 Hi Martin, I was trying your test files out. I placed test_multipleactions.fp7 in library/filemaker server 7/data/databases/martin/ and placed the 3 multiple.xsl files in library/filemaker server 7/web publishing/xslt-template-files/martin/ but when I try http://myhost/fmi/xsl/martin/multiple.xsl I get "The requested file could not be found (file-er0001)" but I can put my own .xsl file in this same location and it will find my file. Am I missing something here? This stuff is driving me crazy er. Thanks, Doug
ddhull Posted March 15, 2005 Posted March 15, 2005 Hi Martin, I was trying your test files out. I placed test_multipleactions.fp7 in library/filemaker server 7/data/databases/martin/ and placed the 3 multiple.xsl files in library/filemaker server 7/web publishing/xslt-template-files/martin/ but when I try http://myhost/fmi/xsl/martin/multiple.xsl I get "The requested file could not be found (file-er0001)" but I can put my own .xsl file in this same location and it will find my file. Am I missing something here? This stuff is driving me crazy er. Thanks, Doug
Martin Brändle Posted March 15, 2005 Posted March 15, 2005 I checked the zip, hope it should be ok (took the zip of the unix shell, because stuffit was complaining with a strange error). Maybe you check the owner:group of the files and their permissions. Of course also the database should have rw on admin:fmsadmin and also the martin folder in databases. Martin
Martin Brändle Posted March 15, 2005 Posted March 15, 2005 I checked the zip, hope it should be ok (took the zip of the unix shell, because stuffit was complaining with a strange error). Maybe you check the owner:group of the files and their permissions. Of course also the database should have rw on admin:fmsadmin and also the martin folder in databases. Martin
Martin Brändle Posted March 15, 2005 Posted March 15, 2005 I checked the zip, hope it should be ok (took the zip of the unix shell, because stuffit was complaining with a strange error). Maybe you check the owner:group of the files and their permissions. Of course also the database should have rw on admin:fmsadmin and also the martin folder in databases. Martin
Martin Brändle Posted March 15, 2005 Posted March 15, 2005 The xsl files should belong to owner fmweb, group fmsadmin and have -rw-rw----. If you unpack them of the zip, they probably have owner ddhull, group fmsadmin and -rw------- only. Martin
Martin Brändle Posted March 15, 2005 Posted March 15, 2005 The xsl files should belong to owner fmweb, group fmsadmin and have -rw-rw----. If you unpack them of the zip, they probably have owner ddhull, group fmsadmin and -rw------- only. Martin
Martin Brändle Posted March 15, 2005 Posted March 15, 2005 The xsl files should belong to owner fmweb, group fmsadmin and have -rw-rw----. If you unpack them of the zip, they probably have owner ddhull, group fmsadmin and -rw------- only. Martin
ddhull Posted March 16, 2005 Posted March 16, 2005 Hi Martin, in your example, what happens when "Reset" is selected? I guess really what I am wondering is, does it call the same page, multiple.xsl, or does it still call multiple2.xsl? By the way, if you have any other small examples you want to share I would certainly be interested in them. You could possibly email them directly. Thanks, Doug [email protected]
ddhull Posted March 16, 2005 Posted March 16, 2005 Hi Martin, in your example, what happens when "Reset" is selected? I guess really what I am wondering is, does it call the same page, multiple.xsl, or does it still call multiple2.xsl? By the way, if you have any other small examples you want to share I would certainly be interested in them. You could possibly email them directly. Thanks, Doug [email protected]
ddhull Posted March 16, 2005 Posted March 16, 2005 Hi Martin, in your example, what happens when "Reset" is selected? I guess really what I am wondering is, does it call the same page, multiple.xsl, or does it still call multiple2.xsl? By the way, if you have any other small examples you want to share I would certainly be interested in them. You could possibly email them directly. Thanks, Doug [email protected]
Martin Brändle Posted March 16, 2005 Posted March 16, 2005 "Reset" just clears your input fields or, if you have predefined the values in <input type="text" name="fieldname" value="predefinedvalue">, resets the fields to those predefined values. It doesn't do anything anything else, i.e. the user stays on the page, the database is not altered. It's the standard <input type="reset" value="buttonlabel"> HTML code that exists since HTML 2.0. Try it out: Fill in some fields, then press Reset. Check another example here: http://www.fmforums.com/threads/showflat.php?Cat=0&Number=139914&an=0&page=2#139914 Your suggestion is worthwhile to consider: Maybe we should have a central repository for standard FMS7A Custom Web Publishing cases (although fmforums is quite good, and I think one can search them with the keyword "Download"). Bryan vonDeylen has started to create one here: http://www.neenah.k12.wi.us/~bvd/xsl/ The question for me is: what is standard, and what is already very individually tailored? Of course this depends on the database structure behind the pages and of the individual look and function of the web design. And then there is also individual programming style. I begin to reuse now certain code snippets (like the trick with the alternatingly colored table rows) or place often used code in templates that are called like subroutines. There is also the FMS7A XLST site assistant which covers some standard situations. I tried it out but was not fond of it. Martin
Martin Brändle Posted March 16, 2005 Posted March 16, 2005 "Reset" just clears your input fields or, if you have predefined the values in <input type="text" name="fieldname" value="predefinedvalue">, resets the fields to those predefined values. It doesn't do anything anything else, i.e. the user stays on the page, the database is not altered. It's the standard <input type="reset" value="buttonlabel"> HTML code that exists since HTML 2.0. Try it out: Fill in some fields, then press Reset. Check another example here: http://www.fmforums.com/threads/showflat.php?Cat=0&Number=139914&an=0&page=2#139914 Your suggestion is worthwhile to consider: Maybe we should have a central repository for standard FMS7A Custom Web Publishing cases (although fmforums is quite good, and I think one can search them with the keyword "Download"). Bryan vonDeylen has started to create one here: http://www.neenah.k12.wi.us/~bvd/xsl/ The question for me is: what is standard, and what is already very individually tailored? Of course this depends on the database structure behind the pages and of the individual look and function of the web design. And then there is also individual programming style. I begin to reuse now certain code snippets (like the trick with the alternatingly colored table rows) or place often used code in templates that are called like subroutines. There is also the FMS7A XLST site assistant which covers some standard situations. I tried it out but was not fond of it. Martin
Martin Brändle Posted March 16, 2005 Posted March 16, 2005 "Reset" just clears your input fields or, if you have predefined the values in <input type="text" name="fieldname" value="predefinedvalue">, resets the fields to those predefined values. It doesn't do anything anything else, i.e. the user stays on the page, the database is not altered. It's the standard <input type="reset" value="buttonlabel"> HTML code that exists since HTML 2.0. Try it out: Fill in some fields, then press Reset. Check another example here: http://www.fmforums.com/threads/showflat.php?Cat=0&Number=139914&an=0&page=2#139914 Your suggestion is worthwhile to consider: Maybe we should have a central repository for standard FMS7A Custom Web Publishing cases (although fmforums is quite good, and I think one can search them with the keyword "Download"). Bryan vonDeylen has started to create one here: http://www.neenah.k12.wi.us/~bvd/xsl/ The question for me is: what is standard, and what is already very individually tailored? Of course this depends on the database structure behind the pages and of the individual look and function of the web design. And then there is also individual programming style. I begin to reuse now certain code snippets (like the trick with the alternatingly colored table rows) or place often used code in templates that are called like subroutines. There is also the FMS7A XLST site assistant which covers some standard situations. I tried it out but was not fond of it. Martin
RussellB Posted March 23, 2005 Author Posted March 23, 2005 Thanks Martin - worked first time. Made a whole bunch of tokens and ran the set_status_code(302) and set_header('Location','target_url'). Works well. Minor problem now...I was using some simple javascript to enforce required fields be filled. I think that the -token.fieldname has confused the javascript... var fieldname = theForm.-token.fieldname.value Any hints? Also I noticed that long text strings sent as tokens seem to slow down the processing of the action. Is that true or just in my imagination?
Martin Brändle Posted March 23, 2005 Posted March 23, 2005 minus signs are not allowed in JavaScript objects. You have to address a form element with form.elements[index_of_your_element], e.g. write theForm.elements[somenumberhere].value For somenumberhere, start counting the elements in your form at 0. It could well be that longer text in tokens might slow down the web publishing. Think of the following process: query (1) --> WPE (2) --> database (3) --> WPE (4) --> XML parser (5) --> XSLT engine (6) --> web server (7) --> browser (8) In (2), the tokens have to be stripped of the query and saved somehow In (4), they are added again as an XML resultset tree in parameter request-query (maybe this already happens in (2)) In (5), the XML parser generates node trees in memory for (6) In (6), node trees are transformed Performance of (2),(4),(5),(6) is probably dependent on the length of the token. My experience is, that for large resultsets (4) is the bottleneck (have made some timings). (6) is always fast. I already suggested to a FileMaker representative that (4) should be improved. Martin
RussellB Posted March 25, 2005 Author Posted March 25, 2005 Thanks again Martin - javascript sorted. With the following code... fmxslt:set_status_code(302) What does 302 mean? I can't find anything about this. Thanks
Martin Brändle Posted March 25, 2005 Posted March 25, 2005 These are the HTTP status codes according to RFC 2616 (HTTP/1.1). 302 belongs to the 300's redirection codes. In the specification it means "Found", sometimes also translated as "Moved Temporarily". It tells the browser to load another URI, given by "Location", than the present one. Martin
RussellB Posted June 7, 2005 Author Posted June 7, 2005 Now I am trying something a little different... I want to use set_status_code(302) to create a new record then load a new page (all in one action) BUT I need to capture a field (auto-enter serial) from the newly created record and pass that on at the same time. This is what I have done: 1. Create a new record <?xslt-cwp-query params="-grammar=fmresultset...&-new"?> 2. Capture the serial number of this new record (using <xsl:for-each select="/fmrs:fmresultset/fmrs:resultset/fmrs:record">) <xsl:variable name="serial-id"><xsl:value-of select="fmrs:field[@name='serial_id']/fmrs:data"/></xsl:variable> 3. Relay to the next page by modifying the HTTP header (but include the new record's serial number) <xsl:variable name="header" select="fmxslt:set_header('Location', concat('abc.xsl?-grammar=fmresultset&-db=abc&-lay=abc&serial=',$serial-id,'&-new'))"/> Error message says can't find variable named serial-id???
Martin Brändle Posted June 7, 2005 Posted June 7, 2005 Yes, because your variable is only valid within the scope (or "context" in XSLT "slang") of the xsl:for-each (see explanation of XSLT variables here), and not outside. xsl:for-each constrains the context of the elements within the xsl:loop to the XPath in the xsl:for-each select="..." . What you can do: - delete the xsl:for-each, it is not needed (anyway you get one record only with -new). - Define your variable like this: <xsl:variable name="serial-id" select="/fmrs:fmresultset/fmrs:resultset/fmrs:record[1]/fmrs:field[@name = 'serial_id']/fmrs:data[1]"/> The scope of the variable should now be within the whole xsl:template. [1] denotes the first entity of a node (similarly [2] the second and so on). From Apache's Xalan-Java XSLT processor website on optimizing performance: <xsl:variable name="..." select="..."/> is faster than <xsl:variable name="..."><xsl:value-of select="..."/></xsl:variable>
Recommended Posts
This topic is 7450 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now