12 Replies Latest reply on Apr 12, 2012 4:43 PM by Malcolm

    XML Export: Generate a Portable File Path for XSL Stylesheets?

    Malcolm

      I have a stylesheet that I have placed in the the Filemaker extensions folder. When I hard code the path the export works normally.

       

      However, I am developing this on a file running under FMS.

       

      Hardcoding the filepath reflects my local setup so I want to use a calculated file path.

       

      When I use a calculated filepath I get an error from the SAX parse engine. SAXParseException: unable to determine file base pathname (Occurred in an unknown entity, at line 0, column 0.)

       

      I figured that the hardcoded path must be right ( at least in my setup ), so I copied the path inserted by filemaker when I hardcode the path and used that. The error still occurs.

       

      How do I make the file path portable?

        • 1. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
          beverly

          I use the desktop (or hardcoded folder on the desktop) or the temp directory (folder). These paths can be obtained with FM functions.

           

          Place the xslt in a container (or text) and export before needed in your routine.

          HTH

          -- sent from my iPhone4 --

          Beverly Voth

          --

          • 2. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
            Malcolm

            I use the desktop (or hardcoded folder on the desktop) or the temp directory (folder). These paths can be obtained with FM functions.

             

             

            Place the xslt in a container (or text) and export before needed in your routine.

             

            I'll try that. I have been trying get(FilemakerPath) & "Extensions/myob_contacts.xsl". I didn't think that it would matter which of the locations I used.

             

            Malcolm

            • 3. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
              beverly

              It's a permission thing, IIRC.

               

              -- sent from my iPhone4 --

              Beverly Voth

              --

              • 4. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                Malcolm

                File Permissions? Let me see...

                 

                I'm under the impression that any read/writes will be done with the permissions of the current desktop user, ie, me.

                 

                I'm on a Mac, I'm the primary user and have admin privileges. My account created the folder and the xsl file so I have read/write permissions on both of those objects. I have read/write permissions on the entire tree. I only want to read the xsl file.

                 

                When I specify the file to use for the xsl transform and I choose "file" and browse for the file I get the following path back "filemac:/Macintosh HD/Applications/FileMaker Pro 11 Advanced/Extensions/CIS/myob_contacts.xsl".  With that file path the script works.

                 

                When I copy that string and choose calculation and paste in the string I get a parse error.

                 

                When I try to generate a path (for reading the xsl file) using DesktopPath or TempFolderPath I get the same error.

                 

                I'm still stumped.

                 

                 

                malcolm

                • 5. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                  beverly

                  FILEMAKER read/writes may depend on the permissions that IT has. Your login to the machine may or may not be the same as the login to the database(s).

                   

                  If you use the two functions:

                  Get ( DesktopPath ) - http://fmhelp.filemaker.com/fmphelp_10/en/html/func_ref2.32.21.html#1041647

                  Get ( TemporaryPath ) - http://fmhelp.filemaker.com/fmphelp_10/en/html/func_ref2.32.74.html#1031578

                   

                  then they can be *dynamic* for eash user.

                   

                  I also test for platform with

                  Get ( SystemPlatform ) - http://fmhelp.filemaker.com/fmphelp_10/en/html/func_ref2.32.72.html

                   

                  , as the platform may have different ways of getting the path.

                   

                  Does that help? I thought you were looking for the DYNAMIC path.

                   

                  Beverly

                  • 6. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                    Malcolm

                    Surely a desktop application carries the current users permissions. No? I have experienced issues with FMS read/write permissions but it is running as a daemon / service. It is started by the OS and is running before any user logs in so it cannot inherit rights from a desktop login. FMPro is a desktop client and has to be started by the user and is then running under the user permissions. I'd love to be corrected if I'm wrong about any of this but I've never experienced problems reading or writing from FMPro when creating PDFs, exporting field contents, etc.

                     

                    I am looking for a dynamic path and I did try placing the xsl on the desktop and using Get(DesktopPath) to generate the filepath and it failed with the same error (SAXParseError). I won't start crying until I try it with Get(TemporaryPath).

                     

                    In your first response you said that it should be possible to store the xsl in a container and export it to the temporary folder. I thought of doing that myself last year and was stymied by the same error that I have been experiencing with this (SAXParseErrors). Perhaps I should login as a different user and see what the results are. I have a WinXP box, so I will try it there too.

                    • 7. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                      ITPC.JosephA

                      Hi Malcom,

                       

                      It sounds to me like you have a syntax error in your XSLT. Have you looked at the log that contains the error? Depending on the OS you are on; it is usually generated and stored in a cryptic location, for example on my Mac (10.6.8) it stores it under:

                       

                      /SnowLeopard/private/var/folders/Az/Azlq3NTHEred2kVxm3hmfu+++TI/-TMP-/HTML.log

                       

                      I use the "Go" menu from the Finder and then the "Go To Folder..." action

                       

                      --

                      Joseph Arzate

                      IT Professional Consultants Inc.

                      • 8. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                        beverly

                        Joseph, when we look at Malcom's original post:

                        "...When I hard code the path the export works normally..."

                        "...When I use a calculated filepath I get an error from the SAX parse engine..."

                        "...How do I make the file path portable?"

                         

                        His "hard-coded" path works (on his local machine),

                        does NOT work when put on the server (the path is NOT the same from the server perspective),

                        does NOT work when calculated (so I'm thinking the calculation is wrong).

                         

                        I don't think it's a syntax error.

                         

                        I've written 100's of XSLT. The best method is to store the XSLT in a field and export to the local DESTOP (in a folder is ok) and use the GET functions I'd previously noted. So put the file there and read from there for use with the export.

                         

                        IF he's calling other XSLT or XML (such as with the document function), then there may be an error internally in the stylesheet.

                         

                        Beverly

                        • 9. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                          ITPC.JosephA

                          Hi Beth,

                           

                          I stand corrected. I focused too much on the SAX Parse engine error. We work and produce both Excel and Word documents using FM/XML/XSLT but we store the XSLT file on a Mapped drive that all users have access to. After reading your post I can see how storing that in a field could be an advantage but does it add an additional layer of complexity to export the information to a new file and then using that newly created export as the path for the XSLT reference? Just curios if you ever run into any issues using this technique.

                           

                          --

                          Joseph Arzate

                          IT Professional Consultants Inc.

                          • 10. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                            beverly

                            Once the file is exported, it need not be exported again, unless you change the file. So, I suppose you could just put it on the user's desktop if you desire. Add it to a KNOWN folder and use that in the dynamic path.

                             

                            Mapped drives can run into problems as well.

                             

                            The "dynamic" path, tho is what works either way.

                             

                            Beverly

                            • 11. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                              ITPC.JosephA

                              Thanks Beth that makes sense.

                               

                              BTW, the only issue we have ever encountered with using a Mapped drive technique is when the server is down and the client can not establish a connection to the Server. And since our FMServer is on the same machine as the mapped drive the user would not be logged into FM.

                               

                              To further prevent any issues we set the Shared folder that contains the XSLT as a Read-only directory to prevent anyone from modifying the XSLT or the contents of the folder. If we ever need to update the XSLT we just override the one file on the Server.

                               

                              It does take a little more to setup each user with a mapped drive, but even that can be automated in Windows by executing a simple batch file upon logon.

                               

                              --

                              Joseph Arzate

                              IT Professional Consultants Inc.

                              • 12. Re: XML Export: Generate a Portable File Path for XSL Stylesheets?
                                Malcolm

                                It sounds to me like you have a syntax error in your XSLT. Have you looked at the log that contains the error?

                                 

                                Thanks for that, I didn't know that an error log was generated. I am presuming that the cryptic path is revealed by Get(TemporaryPath) or is it a different location. If so, how do we determine which of the many -Tmp- folders to search in?

                                 

                                There is now a new twist.

                                 

                                I decided to generate the XSL file on the fly using a virtual table export rather than having stored documents. I made a mistake in the first export and produced a malformed file. The error I got back was Error in parsing XML file (from Xerces). This suggests that the file is being found and interpreted.

                                 

                                Having corrected the mistake in the virtual table export I get back to the same old issue.

                                 

                                When I try to build the file on the fly I get  Error 719 Error in transforming XML using XSL (from Xalan) and the dialog appears saying  SAXParseException: unable to determine file base pathname (Occurred in an unknown entity, at line 0, column 0.) .

                                 

                                The odd thing is that I can use the same xsl file without error if I hard-code the path. Yet Beverly is able to use dynamic paths without problems.

                                 

                                Malcolm