8

I would like to generate some reports from data stored in SharePoint lists. It is possible to query the lists using web services and retrieve the data in a xml data format.

For example, sending a request to my SharePoint site using the following curl commad

curl --ntlm --user "user:pass" -H "Content-Type: text/xml;charset=UTF-8" --data @request.txt --output answer.txt http://intranet/_vti_bin/lists.asmx

With a request.txt file containing

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
        <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <listName>Test</listName>
            <query>
                <Query>
                    <Where>
                        <IsNotNull>
                            <FieldRef Name="Title" />
                        </IsNotNull>
                    </Where>
                </Query>
            </query>
            <viewFields>
                <ViewFields>
                    <FieldRef Name='Title' />
                    <FieldRef Name='Day' />
                </ViewFields>
            </viewFields>
            <QueryOptions>
                <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
                <ViewFieldsOnly>TRUE</ViewFieldsOnly>
            </QueryOptions>
        </GetListItems>
    </soap12:Body>
</soap12:Envelope>

returns an answer from my test list in SharePoint:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
        <GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <GetListItemsResult>
                <listitems 
                    xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
                    xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
                    xmlns:rs='urn:schemas-microsoft-com:rowset'
                    xmlns:z='#RowsetSchema'>
                    <rs:data ItemCount="3">
                        <z:row ows_Title='Yesterday' ows_Day='2014-04-13 00:00:00' />
                        <z:row ows_Title='Today' ows_Day='2014-04-14 00:00:00' />
                        <z:row ows_Title='Tomorrow' ows_Day='2014-04-15 00:00:00' />
                    </rs:data>
                </listitems>
            </GetListItemsResult>
        </GetListItemsResponse>
    </soap:Body>
</soap:Envelope>

Is it possible to send such a request directly from LuaLaTeX and process the response as part of the typesetting process? I know I can write the request to a file using the filecontents package and wrap the curl call in \immediate\write18{curl ...} but I was wondering if a better way exists that take advantage of additional features from LuaLaTeX?

From Google I have found that LuaTeX has luasocket build in, and luaxml from the odsfile package also seems relevant. However, I have no idea how to start using these tools. Therefore my question: Is it possible to query a SharePoint list (or some other web service that returns data in xml format) and parse the result using LuaLaTeX?

  • 1
    Is it possible to send such a request directly from LuaLaTeX -- Yes, but you’re going to have to use an SSL wrapper like luasec to make the requests. Or call the curl binary using os.execute() like Context does. Then use the XML library of your choice to extract the data and process it like any normal document. I’ve never used Sharepoint so I can’t help you with the details. – Philipp Gesang Apr 14 '14 at 18:04
  • Thanks. However, this is basically similar to my current approach with the curl call in \immediate\write18 and a piped input using xmlstarlet to extract what I need from the SharePoint response xml. I was hoping that a more self contained solution existed that only relied on the LuaLaTeX executable and preferably only additional tools in TeXlive or things that can easily ship with the document. – Martin Heller Apr 15 '14 at 10:49
  • If you could drop the hard requirement on Latex, Context should be able to do it out of the box: It too uses curl transparently and comes with a builtin XML parser. Sorry I can’t help you any further. – Philipp Gesang Apr 15 '14 at 17:42
  • I haven't tried Context before, but I would be very interested in some pointers if anybody has tried something similar to what I am attempting in Context. – Martin Heller Apr 15 '14 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.