From:
Tod Harter <tharter [at] giantelectronicbrain.com>
Date:
Wed, 20 Nov 2002 15:46:03 -0500
To:
"Adam Griffiths" <axkit [at] adam-griffiths.co.uk>, <axkit-users [a...
Subject:
Re: A SimpleTaglib and namespaces.
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: axkit-users-unsubscribe [at] axkit.org
> For additional commands, e-mail: axkit-users-help [at] axkit.org
--
Tod G. Harter
Giant Electronic Brain
A SimpleTaglib and namespaces. - Adam Griffiths on 20 Nov 2002 18:03:48 -0000
Re: A SimpleTaglib and namespaces. - Tod Harter on 21 Nov 2002 19:54:47 -0000
Re: A SimpleTaglib and namespaces. - Robin Berjon on 22 Nov 2002 09:50:57 -0000
Re: A SimpleTaglib and namespaces. - Robin Berjon on 22 Nov 2002 15:23:46 -0000
Re: A SimpleTaglib and namespaces. - Robin Berjon on 22 Nov 2002 18:34:13 -0000
Re: A SimpleTaglib and namespaces. - Tod Harter on 22 Nov 2002 14:39:15 -0000
Re: A SimpleTaglib and namespaces. - Tod Harter on 22 Nov 2002 17:33:37 -0000
Re: A SimpleTaglib and namespaces. - Matt Sergeant on 23 Nov 2002 14:42:35 -0000
Re: A SimpleTaglib and namespaces. - Matt Sergeant on 23 Nov 2002 14:48:56 -0000
Re: A SimpleTaglib and namespaces. - Tod Harter on 23 Nov 2002 14:51:55 -0000
Re: A SimpleTaglib and namespaces. - Matt Sergeant on 23 Nov 2002 15:04:59 -0000
Re: A SimpleTaglib and namespaces. - Daisuke Maki on 23 Nov 2002 15:11:55 -0000
Re: A SimpleTaglib and namespaces. - Matt Sergeant on 23 Nov 2002 15:21:24 -0000
Re: A SimpleTaglib and namespaces. - Sebastian Rahtz on 23 Nov 2002 15:35:55 -0000
Re: A SimpleTaglib and namespaces. - Daisuke Maki on 23 Nov 2002 15:36:15 -0000
Re: A SimpleTaglib and namespaces. - Daisuke Maki on 23 Nov 2002 15:38:04 -0000
Re: A SimpleTaglib and namespaces. - Robin Berjon on 25 Nov 2002 14:16:01 -0000
Re: A SimpleTaglib and namespaces. - Robin Berjon on 25 Nov 2002 14:21:32 -0000
Re: A SimpleTaglib and namespaces. - Tod Harter on 25 Nov 2002 16:12:39 -0000
Re: A SimpleTaglib and namespaces. - Tod Harter on 25 Nov 2002 16:18:01 -0000
Back up to archives |
These pages are copyright © 2002 Apache Software Foundation


Index