1

Re: A simple guide to XML reports

This is a bit of an ambitious title but some of the postings I've made on the LRC Technical Forum provide what I think amounts to a basic guide to some simple XML reporting. As I've gradually got to grips with the issues involved, so these XML reports have gradually become more complex and more useful.
So here's the first one. All you need for this one is a text editor, Recorder 6 and a bit of an understanding of how Queries in Access 97 work.

<?xml version="1.0" ?> 
<CustomReport  description="Locations designated in Site_Status as Badger setts"> 
    
    <SQL>       
    SELECT 
        LOCATION.LOCATION_KEY as LOCATION_KEY,
        LOCATION.FILE_CODE as Object,
        LOCATION_NAME.ITEM_NAME as Location, 
        LOCATION.SPATIAL_REF as [Grid ref], 
        LOCATION_DESIGNATION.SITE_STATUS_KEY as [StatusKey], 
        LOCATION_DESIGNATION.REF_CODE as [Reference], 
        LOCATION_DESIGNATION.DATE_FROM as [From], 
        LOCATION_DESIGNATION.DATE_TO as [to], 
        SITE_STATUS.SHORT_NAME as [Status], 
        SITE_STATUS.LONG_NAME as [StatusLong]
    FROM 
        SITE_STATUS INNER JOIN (LOCATION INNER JOIN (LOCATION_NAME INNER JOIN LOCATION_DESIGNATION ON LOCATION_NAME.LOCATION_KEY = LOCATION_DESIGNATION.LOCATION_KEY) ON LOCATION.LOCATION_KEY = LOCATION_NAME.LOCATION_KEY) ON (SITE_STATUS.SITE_STATUS_KEY = LOCATION_DESIGNATION.SITE_STATUS_KEY) AND (SITE_STATUS.SITE_STATUS_KEY = LOCATION_DESIGNATION.SITE_STATUS_KEY)
        <Where keytype="Default">      

    WHERE 
            ((SITE_STATUS.SHORT_NAME)='Badger Sett')
        AND 
                LOCATION_NAME.PREFERRED = 1        

    ORDER BY 
                  Reference 
                     
    </Where>
      
    </SQL>
<Columns>
   <Column name="LOCATION_KEY" position ="1" caption="LOCATION_KEY" visible = "true" column-width="0.5in" />
   <Column name="Location" position ="2" caption="Locations" visible = "true" column-width="0.5in" />
   <Column name="StatusKey" position ="3" caption="StatusKey" visible = "false" />
   <Column name="StatusLong" position ="4" caption="StatusLong" visible = "false" />
   <Column name="Grid ref" position ="5" caption="Grid ref" visible = "true" localwidth="180" />
   <Column name="Object" position ="6" caption="Object" visible = "true" column-width="0.5in" />
   <Column name="Reference" position ="7" caption="Reference" visible = "true" />
   <Column name="Status" position ="8" caption="Status" visible = "true" />
   

</Columns>
</CustomReport>

The function of this is to pick out all your Locations that you have designated as something or other ('Badger Sett' in this case) on the Designation tab of the Locations
The SELECT statement is a fairly simple one that you could readily design in the Query facility within Access.
If you do it this way then just copy and paste the SQL text into your text editor, add the extra text as shown above and tidy everything up into separate lines so that you can understand it.
A useful text editor is UltraEdit which you can find at  IDM Computer Solutions Inc.
Note that I've given some sort of alias name to most of the fields in the first part by using "as xxxxx", the use of square brackets is a good habit since words like "to" and "from" are reserved words and will be interpreted as a command if you don't do it that way. Don't forget that every one of those fields in the first SELECT statement ends in a comma except for the last one.
Next thing to do is save it with a .xml extension (not .txt) in the appropriate folder, mine is C:\Program Files\Recorder 6 Server\User Files\Reports (write another folder below this level to store temporary xmls, a faulty one in this folder can mess things up)
You should now have something that works now; use Reports - Run - select your file from the drop-down box and you have your report.

Later posts I made on the LRC Technical Forum refined some of the above, (e.g. I solved the column width problem in the <columns> section) I shall deal with them in my next posting. Many thanks to Mike Weideli, Chris Roper & Dave Cope for useful tips.

2

Re: A simple guide to XML reports

Darwyn,

Thanks for your efforts on this.  I think that once a decent library of XML reports can be built up this facility will become really useful.  Incidentally, there is a fledgeling page for XML reports on the wiki at http://eim.metapath.org/wiki/index.php? … ML_Reports so perhaps this information could eventually be written up on their as a 'userguide'.

Incidentally, version 6.8 will feature simple ability to export report results grid to Excel files, plus a wizard for a variety of other reports.

Cheers,

John van Breda
Biodiverse IT

3

Re: A simple guide to XML reports

John , further to your thread on the LRC site, Are there any plans afoot to still do these workshops or shall we leave it to the online wiki?

4

Re: A simple guide to XML reports

Further to this,(and X-posted to the LRC gorup),  I had a wee session with Sally Rankin last week who showed me very briefly some of the potential for using .xml reporting. As explained to her then, although we're not quite at this stage with our dataset yet, the time is coming.

Are there any plans or even a consensus to run some workshops? Failing that, then a wee 'getting started kit' such as text editors, basic syntax etc would be really handy. Not only for generating reports, but also tracking down potential bugs from using the report wizard.

Cheers now, Rob.

5

Re: A simple guide to XML reports

Some sort of workshop, perhaps resulting in a published guide would be very welcome. There are a number of things I would very much like to do and am having a great deal of difficulty:
1. Tying those two matching land owner queries together (one for Individuals and one for Organisations) using the Union statement (see my XML reports #2 up to the point where the thread got hijacked!)
I reckon that there is a fault in the way that Recorder's XML deals with Transact XML queries as I've tried every conceivable rearrangement of commands from every conceivable set of guidelines on all available online guides and I cannot get it to work outside Access 2003 - or should I say within Recorder's XML.
2. I used to have a linked table in old Access, one field for the job number and one for the 1Km square (many:one) all managed in a separate Access program which deals with our jobs. In SQL of Recorder 2002 all I had to do was pop that job number in and a search was performed on all the 1Km squares. It produced a really elegant data product and I've just looked again at the "fall back" system I'm having to use now and I'm horrified at the reduction in the quality of service I'm forced to provide to paying customers. How long ago did we all discuss this in detail on this site, how much will I have to pay someone to try and resurrect this, who knows how to do these things in XML.
Where is Mike Weideli? Where is Recorder 6.9?

6

Re: A simple guide to XML reports

Darwyn

In response to point 1, running a query in Access 2003 is not the same as running a Transact SQL query directly, since you are running through the Jet Engine (unless you turn on the pass-through query option). So this might be the reason why your queries don't work inside an XML report. If you want to post the query up I will try to look at it when I get a chance.

There are actually several options for accessing the jobs/grid squares list you are maintaining in Access from an XML report. One possibility would be to upsize your Access database into a SQL server database. Another possibility would be to dump the list of jobs and grid squares as a CSV file and use the CSV table support in the XML reports to import that data and join it to the XML Report query. Finally, if the Access database is on the same server as the SQL Server, then it is possible to directly query it from Transact-SQL.  There are several possibilities but here's an example to get you started:

SELECT a.*
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
   'c:\MSOffice\Access\Samples\northwind.mdb';'admin';'mypwd', Orders) 
   AS a
John van Breda
Biodiverse IT