OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Namespace declaration - good practise

Hi Christophe, I regard DTD as an anachronism - unrelated to modern XML technology (XSD, XPath, XQuery, XSLT) and without future - which I would avoid.

How about writing a tool with the following functionality:
* input: one or more XML files (e.g. XSLTs)
* optional parameter: $ignore - a whitespace-separated list of prefixes identifying namespaces to be ignored
* optional parameter: $add - a whitespace-separated list of prefix/uri pairs to be added
* optional parameter: $upgrade - an XSLT to be modified, see below
* output:
* if no $upgrade: an empty XSLT document with namespace declarations echoing the namespace declarations of the input files
* if $upgrade: a copy of $upgrade, which has namespace declarations echoing the namespace declarations of the input files

The XPath function fn:in-scope-prefixes() and fn:namespace-uri-for-prefix() allow a straightforward copying of in-scope namespaces.

Kind regards,

Am Freitag, 26. April 2019, 16:17:16 MESZ hat Christophe Marchand <cmarchand@oxiane.com> Folgendes geschrieben:

Hello !

I have a lot of XSL that process many business documents. Each XSL
declares at least 15 different business namespaces, excluding technical
namespaces (http://www.w3.org/1999/XSL/Transform,
http://www.w3.org/2001/XMLSchema and so on).

We have problems when creating a new XSL, in copy/paste namespace
declarations, and refactoring (namespace modification) is almost impossible.

So, I'd like to declare namespaces strings as constants, and use these
constants in XSL.

The only way I've found is to declare a DTD with entities, one entity
per namespace :

<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY nsXF "http://www.lefebvre-sarrut.eu/ns/xmlfirst">
<!ENTITY nsAdded "eu:lefebvre-sarrut:mcqueen:publication:added">
<!ENTITY nsXfPub "http://www.lefebvre-sarrut.eu/ns/xmlfirst/publication">
<!ENTITY nsEls "http://www.lefebvre-sarrut.eu/ns/els">

Then, use this DTD in my XSL :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "../../namespaces.dtd">
  xmlns:added="&nsAdded;" ...>

Oxygen have a convinient completion on entities that simplifies declaration.

Am I the only guy to do this ?

Is it a good practise ?

Best regards,


XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS