This queue is for tickets about the XML-Twig CPAN distribution.

Report information
The Basics
Id:
27617
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
s.yona [...] f5.com
Cc:
AdminCc:

BugTracker
Severity:
Critical
Broken in:
(no value)
Fixed in:
  • 3.30
  • 3.31
  • 3.32



Subject: #default creeping into attribute names when map_xmlns is used
This refers to version 3.29. I donn't have other versions to check this issue against. When using map_xmlns, as documented in the POD, sometimes, unprefixed names get a #default prefix. So an attribute 'name' becomes '#default:name' for some reason. This is visible when using the $twig->att('name') or even directly via the data structure: $twig->{att}->{name}. Operating system: GNU/Linux 2.4.21-32.0.1.ELsmp
On Mon Jun 18 00:03:41 2007, SHLOMOY wrote:
Show quoted text
> When using map_xmlns, as documented in the POD, sometimes, unprefixed > names get a #default prefix. > > So an attribute 'name' becomes '#default:name' for some reason. > > This is visible when using the $twig->att('name') or even directly via > the data structure: $twig->{att}->{name}.
Hi, Sorry, it looks like I missed this bug report somehow. Would you have a test case by any chance, that would simplify my job a lot. Thanks. __ mirod
Subject: RE: [rt.cpan.org #27617] #default creeping into attribute names when map_xmlns is used
Date: Thu, 19 Jul 2007 02:51:00 -0700
To: <bug-XML-Twig@rt.cpan.org>
From: "Shlomo Yona" <S.Yona@F5.com>
Hello, Here's an XML file (sitemap.xsd): <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.google.com/schemas/sitemap/0.84" xmlns="http://www.google.com/schemas/sitemap/0.84"> <xsd:annotation> <xsd:documentation> XML Schema for Sitemap files. Last Modifed 2005-05-24 </xsd:documentation> </xsd:annotation> <xsd:element name="urlset"> <xsd:annotation> <xsd:documentation> Container for a set of up to 50,000 document elements. This is the root element of the XML file. </xsd:documentation> </xsd:annotation> <xsd:complexType> <xsd:sequence> <xsd:element ref="url" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="url"> <xsd:annotation> <xsd:documentation> Container for the data needed to describe a document to crawl. </xsd:documentation> </xsd:annotation> <xsd:complexType> <xsd:all> <xsd:element ref="loc"/> <xsd:element ref="lastmod" minOccurs="0"/> <xsd:element ref="changefreq" minOccurs="0"/> <xsd:element ref="priority" minOccurs="0"/> </xsd:all> </xsd:complexType> </xsd:element> <xsd:element name="loc"> <xsd:annotation> <xsd:documentation> REQUIRED: The location URI of a document. The URI must conform to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt). </xsd:documentation> </xsd:annotation> <xsd:simpleType> <xsd:restriction base="xsd:anyURI"> <xsd:minLength value="12"/> <xsd:maxLength value="2048"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="lastmod"> <xsd:annotation> <xsd:documentation> OPTIONAL: The date the document was last modified. The date must conform to ISO 8601 (http://www.w3.org/TR/NOTE-datetime). Example: 2005-05-10 Lastmod may also contain a timestamp. Example: 2005-05-10T17:33:30+08:00 </xsd:documentation> </xsd:annotation> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:minLength value="10"/> <xsd:maxLength value="25"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="changefreq"> <xsd:annotation> <xsd:documentation> OPTIONAL: Indicates how frequently the content at a particular URL is likely to change. The value "always" should be used to describe documents that change each time they are accessed. The value "never" should be used to describe archived URLs. Please note that web crawlers may not necessarily crawl pages marked "always" more often. Consider this element as a friendly suggestion and not a command. </xsd:documentation> </xsd:annotation> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="always"/> <xsd:enumeration value="hourly"/> <xsd:enumeration value="daily"/> <xsd:enumeration value="weekly"/> <xsd:enumeration value="monthly"/> <xsd:enumeration value="yearly"/> <xsd:enumeration value="never"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="priority"> <xsd:annotation> <xsd:documentation> OPTIONAL: The priority of a particular URL relative to other pages on the same site. The value for this element is a number between 0.0 and 1.0 where 0.0 identifies the lowest priority page(s). The default priority of a page is 0.5. Priority is used to select between pages on your site. Setting a priority of 1.0 for all URLs will not help you, as the relative priority of pages on your site is what will be considered. </xsd:documentation> </xsd:annotation> <xsd:simpleType> <xsd:restriction base="xsd:decimal"> <xsd:minInclusive value="0.0"/> <xsd:maxInclusive value="1.0"/> </xsd:restriction> </xsd:simpleType> </xsd:element> </xsd:schema> Here's some code that goes over the XML file and demonstrates the problem (test.pl): use strict; use warnings; use XML::Twig; my $twig=XML::Twig->new( map_xmlns => { 'http://www.w3.org/2001/XMLSchema' => 'xsd' }, ); $twig->xparse(shift); traverse($twig->root); sub traverse { my ($t) = @_; print "gi=|",$t->gi,"|\tprefix=|",$t->ns_prefix,"|\tnamespace=|",$t->namespace,"|\n"; if ($t->atts) { print "attributes of ",$t->gi,":\n"; map {print "\t",$_,"=",$t->att($_)} keys %{$t->atts}; print "\n"; } foreach my $c ($t->children) { traverse($c); } } You'll see in the output (see below), attribute nanes with #default: prefix: Output: gi=|xsd:schema| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:schema: xmlns=http://www.google.com/schemas/sitemap/0.84 xmlns:xsd=http://www.w3.org/2001/XMLSchema #default:targetNamespace=http://www.google.com/schemas/sitemap/0.84 gi=|xsd:annotation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:annotation: gi=|xsd:documentation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:documentation: gi=|#PCDATA| prefix=|| namespace=|http://www.google.com/schemas/sitemap/0.84| attributes of #PCDATA: gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:name=urlset gi=|xsd:annotation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:annotation: gi=|xsd:documentation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:documentation: gi=|#PCDATA| prefix=|| namespace=|http://www.google.com/schemas/sitemap/0.84| attributes of #PCDATA: gi=|xsd:complexType| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:complexType: gi=|xsd:sequence| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:sequence: gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:ref=url #default:maxOccurs=unbounded gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:name=url gi=|xsd:annotation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:annotation: gi=|xsd:documentation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:documentation: gi=|#PCDATA| prefix=|| namespace=|http://www.google.com/schemas/sitemap/0.84| attributes of #PCDATA: gi=|xsd:complexType| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:complexType: gi=|xsd:all| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:all: gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:ref=loc gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:minOccurs=0 #default:ref=lastmod gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:minOccurs=0 #default:ref=changefreq gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:minOccurs=0 #default:ref=priority gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:name=loc gi=|xsd:annotation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:annotation: gi=|xsd:documentation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:documentation: gi=|#PCDATA| prefix=|| namespace=|http://www.google.com/schemas/sitemap/0.84| attributes of #PCDATA: gi=|xsd:simpleType| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:simpleType: gi=|xsd:restriction| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:restriction: #default:base=xsd:anyURI gi=|xsd:minLength| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:minLength: #default:value=12 gi=|xsd:maxLength| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:maxLength: #default:value=2048 gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:name=lastmod gi=|xsd:annotation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:annotation: gi=|xsd:documentation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:documentation: gi=|#PCDATA| prefix=|| namespace=|http://www.google.com/schemas/sitemap/0.84| attributes of #PCDATA: gi=|xsd:simpleType| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:simpleType: gi=|xsd:restriction| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:restriction: #default:base=xsd:string gi=|xsd:minLength| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:minLength: #default:value=10 gi=|xsd:maxLength| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:maxLength: #default:value=25 gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:name=changefreq gi=|xsd:annotation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:annotation: gi=|xsd:documentation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:documentation: gi=|#PCDATA| prefix=|| namespace=|http://www.google.com/schemas/sitemap/0.84| attributes of #PCDATA: gi=|xsd:simpleType| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:simpleType: gi=|xsd:restriction| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:restriction: #default:base=xsd:string gi=|xsd:enumeration| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:enumeration: #default:value=always gi=|xsd:enumeration| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:enumeration: #default:value=hourly gi=|xsd:enumeration| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:enumeration: #default:value=daily gi=|xsd:enumeration| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:enumeration: #default:value=weekly gi=|xsd:enumeration| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:enumeration: #default:value=monthly gi=|xsd:enumeration| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:enumeration: #default:value=yearly gi=|xsd:enumeration| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:enumeration: #default:value=never gi=|xsd:element| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:element: #default:name=priority gi=|xsd:annotation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:annotation: gi=|xsd:documentation| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:documentation: gi=|#PCDATA| prefix=|| namespace=|http://www.google.com/schemas/sitemap/0.84| attributes of #PCDATA: gi=|xsd:simpleType| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:simpleType: gi=|xsd:restriction| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:restriction: #default:base=xsd:decimal gi=|xsd:minInclusive| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:minInclusive: #default:value=0.0 gi=|xsd:maxInclusive| prefix=|xsd| namespace=|http://www.w3.org/2001/XMLSchema| attributes of xsd:maxInclusive: #default:value=1.0 Shlomo.
Show quoted text
-----Original Message----- From: via RT [mailto:bug-XML-Twig@rt.cpan.org] Sent: ד 18 יולי 2007 17:57 To: Shlomo Yona Subject: [rt.cpan.org #27617] #default creeping into attribute names when map_xmlns is used <URL: http://rt.cpan.org/Ticket/Display.html?id=27617 > On Mon Jun 18 00:03:41 2007, SHLOMOY wrote:
> When using map_xmlns, as documented in the POD, sometimes, unprefixed > names get a #default prefix. > > So an attribute 'name' becomes '#default:name' for some reason. > > This is visible when using the $twig->att('name') or even directly via > the data structure: $twig->{att}->{name}.
Hi, Sorry, it looks like I missed this bug report somehow. Would you have a test case by any chance, that would simplify my job a lot. Thanks. __ mirod
OK, fixed in the development version. Please send a _minimal_ text case next time. __ mirod


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.