I believe there is a way to tell XSLT to suppress 'extra' namespace nodes, I 
just don't have the book in front of me right now, plus I haven't actually 
tested that it works, but I do notice that XSP in particular generates a LOT 
of redundant namespace decs, in fact not only the ones you pointed out, but 
sometimes it generates TWO for each tag, one with the prefix and one with the 
default prefix!!!!!!! 

On Wednesday 20 November 2002 01:00 pm, Adam Griffiths wrote:
> Hi all,
>
> I'm writing a SimpleTaglib and would really appreciate some comments. I
> have included example code below to illustrate what I'm doing. I wish to
> have a tag, <GC:makemaintag/>, expanded into an xml fragment by my
> taglib.
>
> First of all, this is my first taglib (:-), have I got the right idea?
> Could I do it a better way?
>
> Second, I've found that the resulting xml fragment has the xml namespace
> written in every tag, which is rather unnecessary. Is there a way to get
> the namespace declared in the parent tag and not in all of it's
> children?
>
> I can live with all the namespaces but seeing as I'm a bit of a perl
> newbie and a taglib newbie it would be great if you can pass your eyes
> over my code below.
>
> Cheers
>
> Adam
>
>
> The xml fragment I wish to build is:
>
>   <maintag>
>     <item>
>       <title></title>
>       <id></id>
>       <value></value>
>     </item><!-- repeated -->
>     <moreinfo></moreinfo>
>   </maintag>
>
> I am using a sub:
>
>   sub makemaintag: struct{
>     #see below for code
>   }
>
> And this results in this xml being output:
>
>   <GC:maintag xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>
>     <GC:moreinfo xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>these items
> were created by an xsp</GC:moreinfo>
>       <GC:item xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>
>          <GC:title xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>first
> item</GC:title>
>   <!-- see bellow for complete list -->
>
>
>
> ##############################################
> Source code, in more detail
> ##############################################
> ______________________________________________
> My Test XSP file
> ______________________________________________
>
> <?xml version="1.0"?>
> <?xml-stylesheet href="." type="application/x-xsp"?>
> <?xml-stylesheet href="test.xsl" type="text/xsl"?>
>
> <xsp:page
> xmlns:xsp="http://www.apache.org/1999/XSP/Core";
> xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";
> language="Perl">
>       <body>
>          <GC:makemaintag/>
>       </body>
> </xsp:page>
>
> ______________________________________________
> My Test Taglib
> ______________________________________________
>
> ### new
> # AxKit XSP taglib
> # Adam Griffiths
> # 20/11/2002 - v.0.01
> ###
>
> package AxKit::XSP::GC;
> use Apache::AxKit::Language::XSP::SimpleTaglib;
> use vars qw/@ISA $NS $VERSION/;
>
> @ISA = ('Apache::AxKit::Language::XSP::SimpleTaglib');
>
> # define the namespace we use
> $NS = 'http://xmlns.domain.co.uk/xsp/GC';
>
> $VERSION = '0.01';
>
>
>     package AxKit::XSP::GC::Handlers;
>     use strict;
>
> sub makemaintag: struct{
>         return << 'EOF';
> my $dynamicvalue='on the fly'; #could be the result of some routine or
> another
> my $item1 = {
>   title=>"first item",
>   id=>'232',
>   value=>'static value'
> };
> my $item2 = {
>   title=>"second item",
>   id=>'232',
>   value=>$dynamicvalue
> };
> my @itemlist;
> push @itemlist, $item1;
> push @itemlist, $item2;
> #could push more items onto @itemlist here
>
> my $children = {
>   item=> \@itemlist, # \@ gives arrayref
>   moreinfo=>'these items were created by an xsp'
> };
> my $maintag = {
>   maintag=>$children
> };
>
> #gives:
> #<maintag>
> #<item>
> #     <title></title>
> #     <id></id>
> #   <value></value>
> #</item>
> #<moreinfo></moreinfo>
> #</maintag>
>
> $maintag;
> EOF
> }
> 1;
> ______________________________________________
> Resulting XML (you may wish to turn line wraping off!)
> ______________________________________________
>
> <GC:maintag xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>
>       <GC:moreinfo xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>these
> items were created by an xsp</GC:moreinfo>
>       <GC:item xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>
>               <GC:title
> xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>first item</GC:title>
>               <GC:id
> xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>232</GC:id>
>               <GC:value
> xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>static value</GC:value>
>       </GC:item>
>       <GC:item xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>
>               <GC:title
> xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>second item</GC:title>
>               <GC:id
> xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>232</GC:id>
>               <GC:value xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>on
> the fly</GC:value>
>       </GC:item>
> </GC:maintag>
>
> ______________________________________________
> My prefered resulting XML, can it be done?
> ______________________________________________
>
> <GC:maintag xmlns:GC="http://xmlns.domain.co.uk/xsp/GC";>
>       <GC:moreinfo>these items were created by an xsp</GC:moreinfo>
>       <GC:item >
>               <GC:title >first item</GC:title>
>               <GC:id>232</GC:id>
>               <GC:value >static value</GC:value>
>       </GC:item>
>       <GC:item>
>               <GC:title>second item</GC:title>
>               <GC:id>232</GC:id>
>               <GC:value>on the fly</GC:value>
>       </GC:item>
> </GC:maintag>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Tod G. Harter
Giant Electronic Brain

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to