Adding lots of files in a defined order
Monday, 21 February 2022 · 3 messages · last reply 22 Feb 2022
JR
Jonathan Robie21 Feb 2022 23:29 #
I have 929 files with names like these:
01-Gen-001.xml
01-Gen-002.xml
01-Gen-003.xml
01-Gen-004.xml
01-Gen-005.xml
01-Gen-006.xml
01-Gen-007.xml
01-Gen-008.xml
01-Gen-009.xml
01-Gen-010.xml
I would like to add them to a new database in the same order that I see if I do $ ls in that directory, without using XInclude to put them inside another node. Is there an easy way to do that?
Jonathan
LQ
Liam R. E. Quin22 Feb 2022 00:52 #
Quoted text · Jonathan Robie · 8 lines
On Mon, 2022-02-21 at 16:28 -0500, Jonathan Robie wrote: > I have 929 files with names like these: > > 01-Gen-001.xml > > I would like to add them to a new database in the same order that I > see if > I do $ ls in that directory,
Are you doing this from within XQuery?
sort(
file:list($dir)[matches(., '\.xml$')]
) ! db:add($db, doc(.), .)
maybe?--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
JR
Jonathan Robie22 Feb 2022 02:19 #
Perfect! Thank you!
Jonathan
Quoted text · Liam R. E. Quin · 26 lines
On Mon, Feb 21, 2022 at 5:52 PM Liam R. E. Quin <liam at fromoldbooks.org> wrote: > On Mon, 2022-02-21 at 16:28 -0500, Jonathan Robie wrote: > > I have 929 files with names like these: > > > > 01-Gen-001.xml > > > > I would like to add them to a new database in the same order that I > > see if > > I do $ ls in that directory, > > Are you doing this from within XQuery? > sort( > file:list($dir)[matches(., '\.xml$')] > ) ! db:add($db, doc(.), .) > > maybe? > > > -- > Liam Quin, https://www.delightfulcomputing.com/ > Available for XML/Document/Information Architecture/XSLT/ > XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. > Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org > >
Written for BaseX 9.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery