validation error using xinclude in tei file

Oxygen general issues.
np18
Posts: 13
Joined: Tue Mar 16, 2021 10:01 pm

validation error using xinclude in tei file

Post by np18 »

Hi,

I have a tei file with a long <encodingDesc> structured like the following example:

Code: Select all

<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader>
        <fileDesc>
            <titleStmt>
                <title type="main" xml:lang="en">Testfile</title>
            </titleStmt>
            <publicationStmt>
                <p>Test</p>
            </publicationStmt>
            <sourceDesc>
                <p>Testfile</p></sourceDesc>
        </fileDesc>
        
        <!-- encodingDesc to be replaced by xi:include -->
        <encodingDesc>
            <charDecl>
                <char></char>
            </charDecl>
        </encodingDesc>
        
    </teiHeader>
    <text>
        <body>
            <p>Some text</p>
        </body>
    </text>
</TEI>
The file is validated using 'http://www.tei-c.org/release/xml/tei/cu ... ei_all.rng'

When I replace the encodingDesc with content from an external file using xi:include, the validation fails.

Code: Select all

<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader>
        <fileDesc>
            <titleStmt>
                <title type="main" xml:lang="en">Testfile</title>
            </titleStmt>
            <publicationStmt>
                <p>Test</p>
            </publicationStmt>
            <sourceDesc>
                <p>Testfile</p></sourceDesc>
        </fileDesc>
        
        <!-- encodingDesc to be replaced by xi:include -->
        <xi:include href="path/to/file.xml" xpointer="encodingDesc" xmlns:xi="http://www.w3.org/2001/XInclude"/>

    </teiHeader>
    <text>
        <body>
            <p>Some text</p>
        </body>
    </text>
</TEI>


path/to/file.xml:

Code: Select all

<encodingDesc xml:id="encodingDesc">
            <charDecl>
                <char></char>
            </charDecl>
        </encodingDesc>
Validation error: 'element "encodingDesc" not allowed here; expected the element end-tag or element "encodingDesc", "profileDesc", "revisionDesc" or "xenoData"'

I have been able to include other elements succesfully using xi:include, the error so far only appears when I try to include the encodingDesc.

Any ideas why this happens?

Thanks in advance!
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: validation error using xinclude in tei file

Post by Radu »

Hi,

You should add the namespace declaration xmlns="http://www.tei-c.org/ns/1.0" on the "encodingDesc" element defined in the separate file, otherwise when the xi:include is expanded it's considered to be in no namespace.
This is why the error is ambiguous, the element "encodingDesc" is allowed there but only if it has a certain TEI namespace.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
np18
Posts: 13
Joined: Tue Mar 16, 2021 10:01 pm

Re: validation error using xinclude in tei file

Post by np18 »

Great, works like a charm! I have suspected an namespace issue, but for some reason did not try to put the namespace in the element to be included... :roll:

Thanks a lot!
Post Reply