12 Replies Latest reply on Mar 15, 2010 5:50 PM by dandrake

    Report output in plain text ?

    dandrake

      Title

      Report output in plain text ?

      Post

      I have a weirdly old-fashioned problem as the days tick down on my 30-day free trial.

       

      The test case for the evaluation is a database that has been running for years in FoxPro -- version 2.6, how's that for old? I see no problem with FileMaker features, of course. The two things that need work are input and output. Importing the full FoxPro data, with Memo fields and all, isn't hard, though the method in the Knowledge Base simply can't work right, at least from FP 2.6. The right method brings the data through OpenOffice spreadsheet -- or, I assume, Genuine(R) Microsoft(R) Excel(R). Details if anyone wants them.

       

      Output produces the odd problem. I want to put out a report in a plain Ascii (or ISO-xxxx) text file. Then another program can process that text into something I want. But I can't find any way that this 21st-century program can do that obsolete task.

       

      To make it perhaps clearer: I want to get out something completely un-pretty with text fields identified by accompanying text, like the following, oncefor each record. (It doesn't really look like this at all, but it gives the sort of flavor of it.)

       

      *new Record*  *field goofus is { some stuff from a table entry here}

      and field foo is { some

      very long stuff

      with imbedded line-breaks also

      and it might be very long}

       

      field99 is{stuff}

      *end page*

       

       

      It's easy to output this in PDF, but that's not a format intended to be read by a text-processing program in Perl or the like!

       

      Have I missed something? Is there an alternate approach to getting the plain text out? I know I could export data in some easy format and write a sort of mail-merge program to massage that -- and reinvent the wheel for implementing report concepts like grouping and breaks and things. Not too hard for this very simple format, but something easier would be better. Or maybe I could generate the usual PDF and find something to extract the text so that an existing program could read it? (Ugh)  Any help would be much appreciated.

       

        • 1. Re: Report output in plain text ?
          dandrake

          Good grief! Actually I don't care what Sarah Palin thinks of it, or Michael, for that matter. PLAIN text, though, would be good.

           

          • 2. Re: Report output in plain text ?
            comment_1

            Filemaker can export standard plain-text formats like tab-delimited and CSV. If you want a custom format, that's possible by exporting as XML and using a custom XSLT stylesheet to transform the output to your specifications.

            • 3. Re: Report output in plain text ?
              philmodjunk

              dandrake wrote:

              Good grief! Actually I don't care what Sarah Palin thinks of it, or Michael, for that matter. PLAIN text, though, would be good.

               


               

              There's an option for editing your posts in the options menu in the top right corner. In this case, I helped out by editing it for you.


              • 4. Re: Report output in plain text ?
                dandrake

                 


                PhilModJunk wrote:

                There's an option for editing your posts in the options menu in the top right corner. In this case, I helped out by editing it for you.


                 

                Why, so there is. Thank you. I'll learn my way around here Real Soon Now.

                 


                • 5. Re: Report output in plain text ?
                  dandrake

                   


                  comment wrote:

                  Filemaker can export standard plain-text formats like tab-delimited and CSV. If you want a custom format, that's possible by exporting as XML and using a custom XSLT stylesheet to transform the output to your specifications.


                   

                  I guess I have to resign myself to taking the tab or csv export (not quite the same as report) and writing a mailmerge thing to put the raw data for each record into a usable form. But I hadn't thought seriously about the XML option and XSLT; I'll have to investigate that. Thanks.

                   


                  • 6. Re: Report output in plain text ?
                    dandrake

                     


                    comment wrote:

                    Filemaker can export standard plain-text formats like tab-delimited and CSV. If you want a custom format, that's possible by exporting as XML and using a custom XSLT stylesheet to transform the output to your specifications.


                     

                     

                    Many thanks. This is clearly the exact thing I needed, and XSLT is an impressively well-done design, or so it appears. But, umm, one little newbie question, if I may. (I've more than one, but I can probably solve the others by Reading The Fine Manual.)

                     

                    I found that the FMPDSORESULT grammar produces a format that I think I understand, with each entry identified by the name of its column. It should be easy to recognize each type and make templates to generate the right output for each. I also find that the XML file says this is deprecated, and I should use FMPXMLRESULT instead.

                     

                    The latter has each entry marked by a <COL></COL> pair, with no kind of identifier of what the field is called. In a procedural language I could loop through the ones in each <ROW>, knowing the order they're written in, and generate the right outputs. I can't figure out how this could be done in XSLT.

                     

                    Could you provide a pointer to some document that answers this, so I can see if I'm on the right track before becoming an expert in XSLT ?

                     


                    • 7. Re: Report output in plain text ?
                      comment_1

                      It can be done, for example by gettitng the position of the current ROW and using it get the name of the FIELD in the same position. But I don't see why you would want to do this: if you want to use the file's field names, it's much more convenient to use the FMPDSORESULT grammar. But then if you modify a field's name, your XML output will change too.

                       

                      With FMPXMLRESULT grammar you can hardcode the output labels, and the only thing you depend on is the export field order.

                      • 8. Re: Report output in plain text ?
                        dandrake

                         


                        comment wrote:

                        It can be done, for example by gettitng the position of the current ROW and using it get the name of the FIELD in the same position. But I don't see why you would want to do this: if you want to use the file's field names, it's much more convenient to use the FMPDSORESULT grammar. But then if you modify a field's name, your XML output will change too.

                         

                        With FMPXMLRESULT grammar you can hardcode the output labels, and the only thing you depend on is the export field order.


                         

                         

                        OK, I guess that explains it (no XML expert here, as you can see). I won't ask why they call the more useful grammar deprecated!

                         

                        Many thanks for putting me on track here.


                        • 9. Re: Report output in plain text ?
                          comment_1

                          Well, "useful" is a relative term. It's not useful to me having to subject my field naming scheme to the format required by the XML recipient. And transforming FMPXMLRESULT to a DSO-like output is fairly trivial.

                          • 10. Re: Report output in plain text ?
                            dandrake

                             


                            comment wrote:

                            Well, "useful" is a relative term. It's not useful to me having to subject my field naming scheme to the format required by the XML recipient. And transforming FMPXMLRESULT to a DSO-like output is fairly trivial.


                             

                            I see. Perhaps some day I'll learn not to state opinions on subjects I'm completely ignorant of. I wonder, is there really any hope for that? :smileyhappy:

                             

                             

                            Meanwhile speaking of expertise, if I may impose on yours for a matter not strictly on the forum's topic -- well, maybe it is, in the light of something I just found out --

                             

                            I have a nice, conditionally working xslt file, pinched from an example in the w3c's doc on html 1.0. Here's the whole simple thing, with some text output changed for clarity:

                             

                            <xsl:stylesheet version="1.0"
                                            xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
                            <xsl:output method="text" encoding="UTF-8"/>   That's Ex Ess Ell Colon Oh Yew Tee ...  dern smileyheads
                                    <xsl:template match="/">report header
                                        <xsl:for-each select="FMPDSORESULT/ROW">
                                            _docatdesc{<xsl:value-of select="TH_CATDESC_M"/>}
                                            page footer
                                        </xsl:for-each>
                                    report footer
                                </xsl:template>
                            </xsl:stylesheet>       

                             

                            The problem with this is probably obvious. But not to me. The problem *symptom* is that the for-each takes exactly zero iterations, and I get the report header and footer with nothing between.

                             

                            All I know, with the aid of a friend who has a distant memory of using XSLT, is that the <xsl:stylesheet > tag is wrong in some way that has to do with the xmlns attribute in the FMPODSRESULT that FileMaker makes. Or so it seems because it works if I make FM put out the XML file directly, and I edit the FMPODSRESULT tag in the generated XML to eliminate the xmlns attribute (or change it to a nonsense attribute). And then I process with an external program like Saxon, and -- magic! It's beautiful! But this is a little more like a blind hack than a solution, no?

                             

                            Oh, and I also know that a few stabs at fixing it, like making the xmlns in the <stylesheet> tag look like the one FileMaker generates, don't work.

                             

                            Any solutions here?

                             

                             






                            • 11. Re: Report output in plain text ?
                              comment_1

                              You must declare the namespace in the <stylesheet> element, and give it a prefix. Then use the prefix when calling the elements within that namespace:

                               

                               

                              <?xml version="1.0" encoding="UTF-8"?>
                              <xsl:stylesheet version="1.0"
                              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:fmp="http://www.filemaker.com/fmpdsoresult">

                              <xsl:output method="text" encoding="UTF-8"/>  
                              <xsl:template match="/">

                              <xsl:for-each select="fmp:FMPDSORESULT/fmp:ROW">
                              <xsl:text>Your text</xsl:text>
                              <xsl:value-of select="fmp:YourField"/>
                              <xsl:text>More text</xsl:text>
                              </xsl:for-each>

                              </xsl:template>
                              </xsl:stylesheet>

                               








                              • 12. Re: Report output in plain text ?
                                dandrake

                                 


                                comment wrote:

                                You must declare the namespace in the <stylesheet> element, and give it a prefix. Then use the prefix when calling the elements within that namespace:

                                 

                                 

                                <?xml version="1.0" encoding="UTF-8"?>
                                <xsl:stylesheet version="1.0"
                                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                xmlns:fmp="http://www.filemaker.com/fmpdsoresult">

                                <xsl:output method="text" encoding="UTF-8"/>  
                                <xsl:template match="/">

                                <xsl:for-each select="fmp:FMPDSORESULT/fmp:ROW">
                                ...

                                 Fantastic!  E pur si muove, as the fellow said. Not only that, I think I can almost see where it makes sense.

                                Now I can buy the program! And start asking naive questions about FileMaker itself.

                                 

                                Heaps more thanks for this.