[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Apply transform to document collection and summari

Subject: Re: Apply transform to document collection and summarize results in single output
From: Sean Tiley <sean.tiley@xxxxxxxxx>
Date: Thu, 2 Feb 2012 09:29:54 -0500
Re:  Apply transform to document collection and summari
Ok, got it working.
Had some troubles with namespaces which still confuses me greatly but
its working.. let me explain.

The source XML files have the followng structure

<SiebelMessage
xmlns="http://www.siebel.com/xml/CPC%20FBE%20Outbound%20Internal%20IO">
    <Message>
        <Account Version="1.0.4">
	   <Value1/>
	   <Value2/>
	   ...
        </Account>
    </Message>
</SiebelMessage>

The stylesheet is as follows

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:agr="http://www.siebel.com/xml/CPC%20FBE%20Outbound%20Internal%20IO
">

    <xsl:template match="/">
        <html>
            <body>
                <h2>In file analysis</h2>
                <table border="1">
                    <tr>
                        <th>Value1</th>
                        <th>Value2</th>
                    </tr>
                    <xsl:for-each

select="collection('file:///c:/tmp/?select=*.xml')/agr:SiebelMessage/agr:Mess
age/agr:Account">
                        <tr>
                            <td>
                                <xsl:value-of select="agr:Value1"/>
                            </td>
                            <td>
                                <xsl:value-of select="agr:Value2"/>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>



I had thought that the matching expression  should be something like
<xsl:template match="/agr:SiebelMessage/agr:Message"), then the
collection select would just have been <xsl:for-each
select="collection('file:///c:/tmp/?select=*.xml'/agr:Account">

No matter what I did I could not get that working, thought I'm sure
it's posible.

Seems I need to read up on namespaces and xslt as there is much I do
not understand

Thanks very much for all the help.
Much appreciated

Sean

On Mon, Jan 30, 2012 at 8:15 AM, Sean Tiley <sean.tiley@xxxxxxxxx> wrote:
> Thank you Ken, very clear.
>
> I'll give it a whirl and get back, likely tomorrow.
>
> Sean Tiley
>
> On Sun, Jan 29, 2012 at 4:37 PM, G. Ken Holman
> <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
>> At 2012-01-29 16:28 -0500, Sean Tiley wrote:
>>>
>>> Hello,
>>> I currently have a template that successfully processes a single xml
file.
>>>
>>> XSLT version 2
>>> Using Saxon-SA 9.1.0.7,
>>>
>>>
>>> I would like to iterate through a folder of XML source documents and
>>> create a single output file
>>
>>
>> The XSLT 2 concept you are looking for is "collections".  There are no
>> standardized URI strings to represent a collection, but Saxon's URI
>> convention is straightforward.
>>
>> You don't show us your data format, but your example could be modified
along
>> the lines of:
>>
>>
>>> My template that successfully processes my source file is
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <xsl:stylesheet version="2.0"
>>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>>
>>> <xsl:template match="Account">
>>
>>
>> You now want to do the logic at the start of processing, so match="/".
>>
>>
>>> <html>
>>>       <body>
>>>               <h2>LogEntries</h2>
>>>          <table border="1">
>>>            <tr bgcolor="#9acd32">
>>>                 <th>Column1</th>
>>>                 <th>Column2</th>
>>>            </tr>
>>
>>
>> At this point you now want to walk all XML files and, I assume, process
the
>> document element named "Account" in each one as a row:
>>
>>  <xsl:for-each select="collection('./?select=*.xml')/Account">
>>
>>
>>>            <tr>
>>>                 <td>
>>>                   <xsl:value-of select="Firstname"/>
>>>                 </td>
>>>                 <td>
>>>                   <xsl:value-of select="Lastname"/>
>>>               </td>
>>>            </tr>
>>
>>
>>  </xsl:for-each>
>>
>>
>>>          </table>
>>>       </body>
>>> </html>
>>> </xsl:template>
>>>
>>> </xsl:stylesheet>
>>>
>>> The output I want is basically a single html file
>>> that includes a table with 2 columns
>>>
>>> Column1                    Column2
>>> Firstname1      Lastname1      (info from file1)
>>> Firstname2      Lastname2      (info from file2)
>>> Firstname3      Lastname3      (info from file3)
>>>
>>>
>>> etc...
>>>
>>> Not clear this is possible.
>>
>>
>> It certainly is.
>>
>>
>>> I could code it in Java / C# to iterate
>>> the docs but kinda feels like it should be possible with just XSLT
>>> Any insight or reading would be appreciated.
>>
>>
>> I hope the above helps.  Check the Saxon documentation for all of the
>> features of the URI for collections.
>>
>> . . . . . . . . . . Ken
>>
>> --
>> Contact us for world-wide XML consulting and instructor-led training
>> Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/uoui9h
>> Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
>> G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
>> Google+ profile: https://plus.google.com/116832879756988317389/about
>> Legal business disclaimers:    http://www.CraneSoftwrights.com/legal
>>
>
>
>
> --
> Sean Tiley
> sean.tiley@xxxxxxxxx



--
Sean Tiley
sean.tiley@xxxxxxxxx

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.