|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Function Copy errorDavid Lee dlee at calldei.comMon Feb 8 09:39:47 PST 2010
This (multiple output files) is a data direct specific feature.
If you'd like to use saxon and XQuery but avoid writing custom java code,
you might consider xmlsh.
www.xmlsh.org
The command "xsplit" will split documents of the sort you describe.
http://www.xmlsh.org/CommandXsplit
Combined with the the command xmove
http://www.xmlsh.org/CommandXmove
Will rename the files in bulk based on an xpath expression.
But the xslt example Mr. Kay suggested looks easier :)
( fyi you can run xslt as a post process to your xquery code in your
language of choice, including xmlsh).
xquery ... | xslt ...
----------------------------------------------------
David A. Lee
http://x-query.com/mailman/listinfo/talk
http://www.calldei.com
http://www.xmlsh.org
--------------------------------------------------
From: "Byomokesh Sahoo" <http://x-query.com/mailman/listinfo/talk>
Sent: Monday, February 08, 2010 9:00 AM
To: <http://x-query.com/mailman/listinfo/talk>
Subject: Re: Function Copy error
> Yes. Its very easy to do using XSLT. Just I want try to do any
> possibility using XQuery.
>
> I saw that
>
> Generating Multiple XML documents Using XQuery
>
> http://www.datadirect.com/developer/data-integration/tutorials/xml-output/index.ssp
>
>
> Thanks
> Byomokesh
>
>
> On Mon, Feb 8, 2010 at 6:32 PM, Michael Kay <http://x-query.com/mailman/listinfo/talk> wrote:
>>
>> There is no function called copy(). What made you think there was, and
>> what did you expect it do?
>>
>> XQuery doesn't really have a way to write multiple result documents. You
>> could do it by returning a sequence of document nodes to the application,
>> and then having the Java application serialize them and write them to
>> disk, but it would have to know where to write them. It's easier to
>> achieve this in XSLT:
>>
>> <xsl:template match="row">
>> <xsl:result-document href="{Term}.xml">
>> <xsl:copy-of select="."/>
>> </xsl:result-document>
>> </xsl:template>
>>
>> Regards,
>>
>> Michael Kay
>> http://www.saxonica.com/
>> http://twitter.com/michaelhkay
>>
>> ________________________________
>> From: http://x-query.com/mailman/listinfo/talk [mailto:http://x-query.com/mailman/listinfo/talk] On
>> Behalf Of Byomokesh Sahoo
>> Sent: 08 February 2010 12:14
>> To: http://x-query.com/mailman/listinfo/talk
>> Subject: Function Copy error
>>
>> Hi,
>>
>> I want split the one xml to multiple xml file using xquery. But it
>> showing error function copy. Please see the below code and give some
>> point out.
>>
>> XML
>>
>> <root>
>> <row>
>> <Term>Hi</Term>
>> <Definition>An informal short greeting.</Definition>
>> </row>
>> <row>
>> <Term>Hello</Term>
>> <Definition>A more formal greeting.</Definition>
>> </row>
>> </root>
>>
>>
>>
>> let $input-document := 'splitfile.xml'
>> let $collection := 'file///D:/temp'
>>
>> for $term-data in doc($input-document)/root/row
>> let $term-name := $term-data/Term/text()
>> let $documentname := concat($term-name, '.xml')
>> let $store-return := copy($collection, $documentname, $term-data)
>>
>> return
>> <store-result>
>> <store>{$term-name}</store>
>> <documentname>{$documentname}</documentname>
>> </store-result>
>>
>> I am using saxon 9.2
>>
>> Thanks
>> Byomokesh
>
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk
>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






