Re: Was: [xsl] mode and moved to Namespaces

Subject: Re: Was: [xsl] mode and moved to Namespaces
From: Jirka Kosek <jirka@xxxxxxxx>
Date: Tue, 19 Apr 2011 23:16:23 +0200
Hash: SHA1

ac wrote:

> The current translation dictionary is setup somewhat like:
> ...
> <word en:title="Mr" f-en:title="Mrs" fr:title="M." f-fr:title="Mme" ... />
> <word en:noun="chair" fr:noun="chaise" ... />
> ...
> all feminine variants can be returned with:
> /dic/word/@*[starts-with(name(.), 'f-')]

Such lookups will tend to be quite slow because matching on name of
element/attribute can't be done using dictionary -- high efficient XSLT
implementations doesn't store element/attributes names for each node,
but they store just number pointing to dictionary with the real
qualified name. This saves memory and makes matching on name very fast.
But if name is not directly present in XPath such fast matching can't be

> all French feminine can be returned with
> /dic/word/@f-fr:*
> all French feminine adjectives can be returned with
> /dic/word/@f-fr:adjective
> all translated English words return form
> /dic/word/@en:*

The trouble with such approach is that you can't change language during
the runtime. You have to pregenerate all queries before running
transformation or use dynamic XPath evaluation (which is not part of
XSLT standard yet).

> all English nouns, whatever gender, can be obtained with something like
> /dic/word/@*:nouns[contains(name(), 'en:')]

If you are using namespaces then this code is not correct. You should
match on namespace name not actual prefix used. So query should be more

/dic/word/@*:nouns[namespace-uri() = 'whatever URI was assigned to en']

> It must be good to know what is right from what is wrong,
> especially with an absolute perspective.
> I have to admit that I have always had some disbelief about absolute
> beliefs,
> but I will keep an open mind, at least just in case.

I consider myself very open-minded. Your usage for namespaces in this
particular case surely works for you, but it's misuse of namespaces.
They were not designed for this and their usage for this several
engineering flaws.

- --
- ------------------------------------------------------------------
  Jirka Kosek      e-mail: jirka@xxxxxxxx
- ------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
- ------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
- ------------------------------------------------------------------
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


Current Thread