Re: [xsl] namespaces declarations treated as boilerplate code

Subject: Re: [xsl] namespaces declarations treated as boilerplate code
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Fri, 15 Aug 2008 16:58:07 +0300
Hi Robert,

No, we do not provide that kind of functionality in oXygen.
Looking into that it turns to be impossible to implement that correctly, as the namespace declaration can be used at runtime, see below an example:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0"
xmlns:test="http://www.oxygenxml.com/example";>
<xsl:param name="t" select="concat('te', 'st')"/>
<xsl:template match="/">
<result>
<xsl:element name="{$t}:x"></xsl:element>
</result>
</xsl:template>
</xsl:stylesheet>


If the xmlns:test namespace declaration is removed then you will get a runtime error if you run the stylesheet without specifying the t parameter, but if you specify t with the value 'xsl' then there is no error if the namespace declaration is removed.

Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Robert Koberg wrote:
Hi Andrew (and Syncro :) ),

When working with documents that have alot of namespaces, I generally
copy over a root element from a previous document out of laziness.

I have always wanted a feature in an IDE (oXygen) that is similar to
java IDEs where you can organize imports. But, instead of imports I
would like it to organize namespaces. Click a button/menu-item and any
namespaces not used in the XML or XSL are removed of off the root
element (and descedants are normalized to the most appropriate level?).

Now George will probably post saying oXygen already has this feature
somewhere I haven't looked :)

best,
-Rob


On Mon, 2008-08-11 at 13:19 +0100, Andrew Welch wrote:
Given two stylesheets with the same namespaces defined at the top
where one imports the other - what happens when the module is
compiled?

I ask because it seems it's very typical for organisations to use the
same xsl:stylesheet element with all namespaces declared and prefixes
excluded etc for every stylesheet regardless of whether that
particular stylesheet uses the namespace or not - like its some sort
of boilerplate code that's copied to every new stylesheet.  Personally
I don't like, and think it's bad practice, and I wonder if there's a
good reason to back up my dislike...?   (for example import precedence
work that could be avoided/reduced)



thanks

Current Thread