On 6/28/22 11:50, Madlik, Monika (LNG-VIE) wrote:

we are using XMLMind Professional Edition 9.5.1  and I have a problem with my DTD and an additional needed nbsp-declaration within my template.

In my xxe-file I declared the DTD like this:

<cfg:dtd systemId="dtd/artikel_intern.dtd"/>

This XXE configuration element simply means that you want XXE to validate your documents against "dtd/artikel_intern.dtd" even if your documents do not start with a <!DOCTYPE> pointing to a DTD. Nothing more than this.

More information here: http://www.xmlmind.com/xmleditor/_distrib/doc/configure/dtd.html

Please also carefully read the warning note found at the end of this page.




<cfg:dtd> is seldom, if ever, used. Generally when a DTD is being used to validate a XML document, the best practice is to start your XML document with the corresponding <!DOCTYPE> declaration.

DocBook v4.5 example:

* Template:
---
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd";>
<article>
  <articleinfo>
    <title></title>
...
---

* docbook.xxe does NOT contain <cfg:dtd>

* DocBook XML catalog:

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
         prefer="public">
  <public publicId="-//OASIS//DTD DocBook XML V4.5//EN"
          uri="dtd/V4.5/docbookx.dtd"/>
</catalog>





So, when I open a template with this xxe-file, it’s automatically validated.

BUT – in my template I have another declaration included:

<!DOCTYPE artikel [<!ENTITY nbsp "&#160;">]>

So if a user opens a template, my expectation is, that the template is validated against the given DTD AND when I save the file, that the additional declaration (<cfg:dtd systemId="dtd/artikel_intern.dtd"/>) is included in the saved xml-file. BUT when I save my file, the additional declaration is not existent in the saved file anymore.

That's normal. Configuration element:

<cfg:dtd systemId="dtd/artikel_intern.dtd"/>

never, ever, caused XXE to add:

<!DOCTYPE artikel systemId="dtd/artikel_intern.dtd">

to the saved documents.

XXE never adds a DTD (or a schema) declaration to a saved document.

Such DTD declaration must be found *beforehand* in the document being edited (that is, File|Open) and in the documents templates (that is, File|New).




In the old versions this wasn’t a problem. Is there any possibility to do this in version 9.5.1 as well?

No. Sorry.




I need the additional declaration (<!DOCTYPE artikel [<!ENTITY nbsp "&#160;">]>) mandatory in my saved file. Otherwise I have a problem with further transformations …


I'm sorry but I don't understand.

I don't see why you would have problems with further transformations.

Except if your documents are saved using the US-ASCII encoding (e.g. your artikel documents starts with <?xml version="1.0" encoding="US-ASCI"?>), the nbsp characters are really there in the saved document but as plain characters (that is, as Unicode code point U+00A0), not as a character entity reference (that is, not as "&#160;" or "&#xA0;" or "&nbsp;").




FYI:

--> If, for any reason, you want to always save nbsp characters as a character entity reference, in "Options|Preferences", Save section,

a) Check "Save characters outside encoding as entity references"

b) Type:
---
160
---
in the "In addition to characters outside the encoding, save the following characters as entity references" field.

See http://www.xmlmind.com/xmleditor/_distrib/doc/help/saveOptions.html#saveCharsAsEntityRefs



OR



--> For maximum interchange compatibility, please consider this best practice:

1) Removing
<cfg:dtd systemId="dtd/artikel_intern.dtd"/>
from your .xxe file. This configuration element is really XXE specific.

2) Adding

<!DOCTYPE artikel systemId="dtd/artikel_intern.dtd" [
  <!ENTITY nbsp "&#160;">
]>

to all your existing artikel documents and to all your artikel templates.

3) Adding to the directory containing your artikel.xxe, an XML catalog instructing XXE and all XML-catalog-aware software where to find a local copy of "artikel_intern.dtd".

For example, artikel_catalog.xml:
---
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <system systemId="dtd/artikel_intern.dtd"
          uri="file:///Users/monika/xml/dtd/artikel_intern.dtd"/>
</catalog>
---

More information here: https://xerces.apache.org/xml-commons/components/resolver/resolver-article.html




--
XMLmind XML Editor Support List
xmleditor-support@xmlmind.com
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to