speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
292 stars 36 forks source link

xi:include warning (VSCode) #548

Closed Cicorione closed 6 months ago

Cicorione commented 6 months ago

Hi Patrick, Merry Christmas!!! πŸŽ„

I am following this instructions:

image

However VSCode is reading it as issue:

image

na-fonts.xml

<Layout xmlns="urn:speedata.de:2009/publisher/en">

    <!-- FONTS DEFINITIONS -->

    <LoadFontfile name="Serpentine-Medium" filename="Serpentine-Medium.otf" mode="harfbuzz" />
    <LoadFontfile name="Serpentine-Bold" filename="Serpentine-Bold.otf" mode="harfbuzz" />
    <LoadFontfile name="Serpentine-BoldOblique" filename="Serpentine-BoldOblique.otf" mode="harfbuzz" />
    <LoadFontfile name="Oswald-Light" filename="Oswald-Light.ttf" mode="harfbuzz" features="+frac" />
    <LoadFontfile name="Oswald-Bold" filename="Oswald-Bold.ttf" mode="harfbuzz" features="+frac" />

    <DefineFontfamily fontsize="8" leading="10" name="bullet">
        <Regular fontface="Oswald-Light" />
        <Bold fontface="Oswald-Bold" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="14" leading="16" name="title">
        <Regular fontface="Oswald-Light" />
        <Bold fontface="Oswald-Bold" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="14" leading="12" name="new">
        <Regular fontface="Serpentine-BoldOblique" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="10" leading="12" name="subtitle">
        <Regular fontface="Oswald-Bold" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="15" leading="17" name="headerfooter">
        <Regular fontface="Serpentine-Medium" />
        <Bold fontface="Serpentine-Bold" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="10" leading="12" name="pagenum">
        <Regular fontface="Serpentine-Bold" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="15" leading="17" name="opensecname">
        <Regular fontface="Serpentine-Bold" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="30" leading="17" name="opensecnamebig">
        <Regular fontface="Serpentine-Bold" />
    </DefineFontfamily>

    <DefineFontfamily fontsize="18" leading="20" name="feature">
        <Regular fontface="Serpentine-Medium" />
        <Bold fontface="Serpentine-Bold" />
    </DefineFontfamily>

    <!-- No Hyphenation -->

    <DefineTextformat name="nohyphen" alignment="leftaligned" hyphenate="no" />

</Layout>

Publisher

Version: 4.15.18

Thanks!!! πŸ™

Cicorione commented 6 months ago

Ok... I rectify...

Not sure what I am doing wrong but it is reading the first entry (na-fonts.xml) only:

<Layout xmlns="urn:speedata.de:2009/publisher/en"
  xmlns:sd="urn:speedata:2009/publisher/functions/en"
  xmlns:xi="http://www.w3.org/2001/XInclude" >

        <!-- LOAD FONTS DEFINITIONS -->

    <xi:include href="na-fonts.xml"/>

    <!-- LOAD COLORS DEFINITIONS -->

    <xi:include href="na-colors.xml"/>

    <!-- LOAD GRAPHICS DEFINITION -->

    <xi:include href="na-graphics.xml"/>

    <!-- LOAD MASTER PAGES -->

    <xi:include href="na-masters.xml"/>

       [...]
</Layout>

Thus I moved this entry in the data file as suggested here:

image

<catalog xmlns:xi="http://www.w3.org/2001/XInclude">

   <!-- LOAD FONTS DEFINITIONS -->
   <xi:include href="na-fonts.xml"/>

   <!-- LOAD COLORS DEFINITIONS -->
   <xi:include href="na-colors.xml"/>

   <!-- LOAD GRAPHICS DEFINITION -->
   <xi:include href="na-graphics.xml"/>

   <!-- LOAD MASTER PAGES -->
   <xi:include href="na-masters.xml"/>

   <xi:include href="sec02.xml"/>

   <!-- <xi:include href="sec03.xml"/> -->
   <!-- <xi:include href="sec04.xml"/> -->
   <!-- <xi:include href="sec05.xml"/> -->
   <!-- <xi:include href="sec06.xml"/> -->
   <!-- <xi:include href="sec07/xml"/> -->
   <!-- <xi:include href="sec08.xml"/> -->
   <!-- <xi:include href="sec09.xml"/> -->
   <!-- <xi:include href="sec16.xml"/> -->
</catalog>

But Publisher is telling that is wrong as well... πŸ€·β€β™‚οΈ

Thanks!!! πŸŽ„πŸŽ„πŸŽ„

Cicorione commented 6 months ago

Updates...

The documentation I was reading it wasn't updated. I followed the online documentation although I am still doing something wrong:

image

image

Ok... I read this:

Info

This command is obsolete. Use Layout instead

I am officially confused... πŸ˜΅β€πŸ’« However it worked... :thinking:

Cicorione commented 6 months ago

Last update, I reverted everything as explained here:

https://doc.speedata.de/publisher/en/basics/fileorganization/#ch-splitlayout

However works only na-fonts.xml even though is marked as issue:

image

all the external xml use this syntax:

<Layout
  xmlns="urn:speedata.de:2009/publisher/en">

    <!-- Colors -->

    <DefineColor name="npgray" model="cmyk" c="0" m="0" y="0" k="53" />
    <DefineColor name="darknpgray" model="cmyk" c="0" m="0" y="0" k="21" />

    <!-- <DefineColor name="npyellow" model="cmyk" c="0" m="30" y="90" k="0" /> -->
    <DefineColor name="npyellow" model="RGB" r="255" g="178" b="25" alpha="100"/>
    <DefineColor name="npyellowA" model="RGB" r="255" g="178" b="25" alpha="80"/>
    <DefineColor name="npyellowAA" model="RGB" r="255" g="178" b="25" alpha="60"/>
    <DefineColor name="npyellowAAA" model="RGB" r="255" g="178" b="25" alpha="40" />
    <DefineColor name="npyellowAAAA" model="RGB" r="255" g="178" b="25" alpha="20" />

</Layout>

Thanks! πŸ™ πŸŽ„

LdBeth commented 6 months ago

This is an issue with the XSD Schema validation that the validator comes with VSCode does not handle the XInclude instructions automatically. I think you can safely ignore these syntax error marked by VSCode. A better validator like jing.jar can handle XInclude instructions without issue. Also you could try RelaxNG based validator plugin like Scholarly XML for VSCode, which I believe unlike XSD Schema, allow foreign nodes like XInclude instructions.

pgundlach commented 6 months ago

I will try to add the xinclude to the schema.

Cicorione commented 6 months ago

@LdBeth

Thanks for the clarification and thanks to suggest an alternative Schema validator.

@pgundlach however I did not understand why is not reading all my xi:include, is it because xi:include is not defined in the schema? Did I use it the wrong way?

As I wrote here using the <Include> tag worked even though you labeled it as obsolete.

Thanks and Happy New Year to both! 🍾

pgundlach commented 6 months ago

Does switching to Relax NG schema solve the problem?

Edit the catalog-schema-en.xml file so it reads:

<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="urn:speedata.de:2009/publisher/en" uri="layoutschema-en.rng"/>
</catalog>

(change the file extension of the layoutschema-en.xsd to .rng)

The path to the catalog can be found in the vscode setting xml.catalogs. It should already have an entry such as publisher/schema/catalog-schema-en.xml

pgundlach commented 6 months ago

BTW Happy new year, too!

Cicorione commented 6 months ago

Hi Patrick, I am afraid that I did not understand how to use the XML Scholarly validator...

This doesn't work:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model
  href="https://vault.tei-c.org/P5/current/xml/tei/custom/schema/relaxng/tei_all.rng"
  schematypens="http://relaxng.org/ns/structure/1.0"
  type="application/xml"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" />

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">

This either:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model
  href="/usr/share/speedata-publisher/schema/layoutschema-en.rng"
  schematypens="http://relaxng.org/ns/structure/1.0"
  type="application/xml"?>
<TEI xmlns="urn:speedata.de:2009/publisher/en" />

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">

😩

LdBeth commented 6 months ago

I think to reference a local schema, the URI syntax is file:///usr/share/speedata-publisher/schema /layoutschema-en.rng

Cicorione commented 6 months ago

Thanks, this worked out:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model
  file="///usr/share/speedata-publisher/schema/layoutschema-en.rng"
  schematypens="http://relaxng.org/ns/structure/1.0"
  type="application/xml"?>

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">
[...]
</Layout>

Publisher read all the xi:include and let the layout being properly designed, however I haven't been able to make the suggestions/autocompletion working yet... πŸ€”

Cicorione commented 6 months ago

Thanks, this worked out:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model
  file="///usr/share/speedata-publisher/schema/layoutschema-en.rng"
  schematypens="http://relaxng.org/ns/structure/1.0"
  type="application/xml"?>

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">
[...]
</Layout>

Publisher read all the xi:include entries and let the layout being properly designed, however I haven't been able to make the suggestions/autocompletion working yet and it looks like I am not alone: https://github.com/raffazizzi/vscode-sxml/issues/20

Anyway as suggested in the same documentation this plugins requires additional other plugins to close tags:

Recommended extensions

For a better XML editing experience we recommend also installing the following extensions:

Auto Close Tag Auto Rename Tag Close HTML/XML tag

Cicorione commented 6 months ago

Perhaps it would work even with RH XML plugin using RelaxNG instead of XML schema... πŸ€” Tomorrow I'll give it a try!

pgundlach commented 6 months ago

I assumed you use the RedHat XML plugin. Sorry. I should have asked. I have instructions here: https://doc.speedata.de/publisher/en/appendix-schema-assigning/schema-vscode/

Cicorione commented 6 months ago

Patrick, I thought that you were asking me to test the other validator, and I was really interested in it because the RH XML plugin has a nasty memory behavior and suddenly it fills out all my RAM and my SWAP let the VSCode crashing on my cheap crapbook.

Cicorione commented 6 months ago

So the author of XML Scholarly came to rescue me and provided the solution:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model 
  href="https://raw.githubusercontent.com/speedata/publisher/develop/schema/layoutschema-en.rng" 
  type="application/xml"
  schematypens="http://relaxng.org/ns/structure/1.0"?>

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">
  [...]
</Layout>

However I am not sure this is correct: href="https://raw.githubusercontent.com/speedata/publisher/develop/schema/layoutschema-de.rng"

Perhaps I should use: href="file:///usr/share/speedata-publisher/schema/layoutschema-en.rng"... πŸ€” (which is not currently working)

Anyway this is cool now there are two ways to use Schema/RelaxNG with VScode, perhaps you can provide an official link instead of this: https://raw.githubusercontent.com/speedata/publisher/develop/schema/layoutschema-en.rng; unless this is totally legitimate... Thanks! πŸ™

pgundlach commented 6 months ago

Both href="https://raw.githubusercontent.com/speedata/publisher/develop/schema/layoutschema-de.rng" and href="file:///usr/share/speedata-publisher/schema/layoutschema-en.rng" could work, however with the RedHat XML mode only the local files seem to work.

pgundlach commented 6 months ago

This issue can be closed?

Cicorione commented 6 months ago

I say yes, so to use xi:include it must be used RelaxNG instead of XML Schema, is that correct?

Thanks... πŸ™

pgundlach commented 6 months ago

That is correct and I have added a note in the documentation for the next release. Thank you for opening this issue.

Cicorione commented 6 months ago

Only for the record local RelaxNG files can (on *nix*) recalled by Scholarly XML this way:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model 
  href="/usr/share/speedata-publisher/schema/layoutschema-en.rng" 
  type="application/xml"
  schematypens="http://relaxng.org/ns/structure/1.0"?>

Thanks πŸ™