xml-model declaration for teiCorpus in exist-db

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

xml-model declaration for teiCorpus in exist-db

Easterly, Joseph
Hi,

I've created an xquery file (see below) which generates a teiCorpus document from a collection of TEI files. I've also created a TEI customization. Is there a way to have xquery or eXist insert an <?xml-model ?> statement at the head of the corpus document, with the URL pointing to my TEI customization RNG file? I've noticed that inside the corpus file, these xml-model statements appear before every TEI element.

thanks!

Joe Easterly
Digital Humanities Librarian
University of Rochester River Campus Libraries

xquery version "3.0";
declare default element namespace "http://www.tei-c.org/ns/1.0";
declare option exist:serialize "method=xml media-type=text/xml";
declare variable $collection := collection('/db/mcelroy/tei');

(:BEGIN-SCRIPT-DOCUMENTATION
|TITLE Corpus Generator for Nellie McElroy Ledgers
|CREATOR Joe Easterly
|UPDATED 2018-05-30
|DESCRIPTION This script collects TEI files from the Nellie McElroy ledgers into a corpus file.
|LICENSE This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International
         License. To view a copy of this license, visit
         http://creativecommons.org/licenses/by-sa/4.0/.
END-SCRIPT-DOCUMENTATION
:)
<teiCorpus>
   
<teiHeader>
       
<fileDesc>
           
<titleStmt>
               
<title>Nellie McElroy Ledger</title>
           
</titleStmt>
           
<publicationStmt>
               
<p>Released by the University of Rochester River Campus Libraries</p>
           
</publicationStmt>
           
<sourceDesc>
               
<p>Nellie L McElroy Journal, 1913-1916. Manuscript Collection CY.21. Journal of work
                    as Rochester's first policewoman.
</p>
           
</sourceDesc>
       
</fileDesc>
   
</teiHeader>
    {
       
for $collItem in $collection
       
let $page := base-uri($collItem)
       
return
           
doc($page)
    }
</teiCorpus>


Reply | Threaded
Open this post in threaded view
|

Re: xml-model declaration for teiCorpus in exist-db

Syd Bauman-9
HI Joe!

I don't speak XQuery well enough to do this off the top of my head
(plenty of others on this list can), but it is easy to do in XSLT,[1]
so it is probably easy in XQuery, too.

But it is worth quickly pointing out that (what I think is) your
instinct is right: as I read the spec[2], an 'xml-model' processing
instruction is only used when it is a child of the document root that
occurs before the outermost element. So those that appear in every
TEI element may be useful to humans, but should be ignored by XML
processors.

Notes
-----
 [1] <xsl:processing-instruction name="xml-model">href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"</xsl:processing-instruction>
 [2] https://www.w3.org/XML/2010/01/xml-model/

> I've created an xquery file (see below) which generates a teiCorpus
> document from a collection of TEI files. I've also created a TEI
> customization. Is there a way to have xquery or eXist insert an <?xml-model
> ?> statement at the head of the corpus document, with the URL pointing to
> my TEI customization RNG file? I've noticed that inside the corpus file,
> these xml-model statements appear before every TEI element.
Reply | Threaded
Open this post in threaded view
|

Re: xml-model declaration for teiCorpus in exist-db

Peter Stadler
In reply to this post by Easterly, Joseph
Hi Joe,

see https://www.w3.org/TR/xquery-31/#id-computed-pis for constructing processing instructions in XQuery.
e.g. `processing-instruction {'xml-model'} {'href="http://www.tei-c.org/Vault/P5/3.3.0/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0“'}` will add a xml model PI for the current TEI_all schema.


BTW, your loop could probably be reduced to `$collection//tei:TEI`. This would also remove the document PIs.

Best
Peter

> Am 30.05.2018 um 16:28 schrieb Joe Easterly <[hidden email]>:
>
> Hi,
>
> I've created an xquery file (see below) which generates a teiCorpus document from a collection of TEI files. I've also created a TEI customization. Is there a way to have xquery or eXist insert an <?xml-model ?> statement at the head of the corpus document, with the URL pointing to my TEI customization RNG file? I've noticed that inside the corpus file, these xml-model statements appear before every TEI element.
>
> thanks!
>
> Joe Easterly
> Digital Humanities Librarian
> University of Rochester River Campus Libraries
>
> xquery version "3.0";
> declare default element namespace "http://www.tei-c.org/ns/1.0";
> declare option exist:serialize "method=xml media-type=text/xml";
> declare variable $collection := collection('/db/mcelroy/tei');
>
> (:BEGIN-SCRIPT-DOCUMENTATION
> |TITLE Corpus Generator for Nellie McElroy Ledgers
> |CREATOR Joe Easterly
> |UPDATED 2018-05-30
> |DESCRIPTION This script collects TEI files from the Nellie McElroy ledgers into a corpus file.
> |LICENSE This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International
>          License. To view a copy of this license, visit
>          http://creativecommons.org/licenses/by-sa/4.0/.
> END-SCRIPT-DOCUMENTATION
> :)
> <teiCorpus>
>     <teiHeader>
>         <fileDesc>
>             <titleStmt>
>                 <title>Nellie McElroy Ledger</title>
>             </titleStmt>
>             <publicationStmt>
>                 <p>Released by the University of Rochester River Campus Libraries</p>
>             </publicationStmt>
>             <sourceDesc>
>                 <p>Nellie L McElroy Journal, 1913-1916. Manuscript Collection CY.21. Journal of work
>                     as Rochester's first policewoman.</p>
>             </sourceDesc>
>         </fileDesc>
>     </teiHeader>
>     {
>         for $collItem in $collection
>         let $page := base-uri($collItem)
>         return
>             doc($page)
>     }
> </teiCorpus>
>