Huditsch, Roman (LNG-VIE) wrote: > > I have a very strange behaviour with namespaces in my configuration of > XMLMind v3.6, which didn't occur before.
No. This behavior exists since v2.0. > I have a valid XML file: > > <?xml version="1.0" encoding="UTF-8"?> > <norm freigegeben="ja" id="eg-lmh" > xsi:schemaLocation="http://www.lexisnexis.at/schema/norm > G:\Gesetzestextredaktion\schema\norm.xsd" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://www.lexisnexis.at/schema/norm"> > <metadaten> > <abkuerzung>EG/LM-HygieneV Allg.</abkuerzung> > <normgeber>EU</normgeber> > </metadaten> > </norm> > > If I load it into XXE and save it as it is, two namespaces get > additionaly added: > > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:ns="http://www.lexisnexis.at/schema/norm" > > Is it possible that XXE interprets the default namespace in my source > document in a wrong way? No, not at all. > I haven't found anything in my config files where these ns might get > added, so I suppose that > it comes directly from the app. Yes but there is no bug here. This should not trouble you: who cares about a few harmless namespaces and/or prefixes automatically ``imported'' by XXE? > When I open the document in XXE and go to Tools/Declare namespaces these > two are displayed there, too. > > Do you have any idea what's wrong with that? > Nothing is wrong here. This is the expected behavior. [1] When you define no prefix for the targetNamespace of a schema, XXE adds a "ns" (or "ns2" or "ns3", etc) one. Just in case! [2] When your document is conforming to a schema, all the namespaces and their prefixes specified in the schema are automatically added to the instance. This saves you the effort of manually defining such namespaces and prefixes using "Tools/Declare namespaces". Example: your schema makes use of namespace "http://www.lexisnexis.at/schema/norm" with prefix "norm" and of namespace "http://www.lexisnexis.at/schema/norm2" with prefix "norm2". Your document template only contains elements belonging to "http://www.lexisnexis.at/schema/norm". You forgot to declare "http://www.lexisnexis.at/schema/norm2" because the document template didn't need it. The user adds an element belonging to "http://www.lexisnexis.at/schema/norm2" because the schema allows to do this. What prefix to use for this one? Answer: "norm2" because you specified it in your *schema*. Note that XXE also ``imports'' namespaces and their prefixes when you cut and paste XML using the clipboard! --> Right approach: predefine *all* possible namespaces in your document templates. Do not forget to specify a prefix even for the default namespace. DocBook 5 example: --- <article version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:html="http://www.w3.org/1999/xhtml"> <title></title> <section> <title></title> <para></para> </section> </article> --- If you do this, XXE will not feel the need to import namespaces and their prefixes from the schema.

