Skip Menu |

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

Report information
The Basics
Id: 3865
Status: resolved
Priority: 0/
Queue: XML-XUpdate-LibXML

People
Owner: Nobody in particular
Requestors: az+rtcpan [...] bond.edu.au
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.4.0
Fixed in: (no value)



Subject: does not work with namespace defaulting
updating a document like the included bookstore example does not work if namespace defaulting is used. as soon as a prefix is given things work again. symptoms: the document is not changed at all (except indentation) and xupdate -debug tells you only "applying <xupdate:insert-before select"... but nothing about "instruction <xupdate:insert-before"... regards az Show quoted text
---bad document--- <?xml version="1.0"?> <BookStore xmlns="http://www.books.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.books.org/BookStore.xsd"> <Book> <Title>My Life and Times</Title> <Author>Paul McCartney</Author> <Date>1998</Date> <ISBN>1-56592-235-2</ISBN> <Publisher>McMillin Publishing</Publisher> </Book> <Book> <Title>Illusions The Adventures of a Reluctant Messiah</Title> <Author>Richard Bach</Author> <Date>1977</Date> <ISBN>0-440-34319-4</ISBN> <Publisher>Dell Publishing Co.</Publisher> </Book> <Book> <Title>The First and Last Freedom</Title> <Author>J. Krishnamurti</Author> <Date>1954</Date> <ISBN>0-06-064831-7</ISBN> <Publisher>Harper &amp; Row</Publisher> </Book> </BookStore> ---bad document---
---update--- <?xml version="1.0"?> <xupdate:modifications version="1.0" xmlns:xupdate="http://www.xmldb.org/xupdate"> <xupdate:insert-before select="/BookStore/Book[1]" > <xupdate:element name="address"> <xupdate:attribute name="id">2</xupdate:attribute> <fullname>Lars Martin</fullname> <born day='2' month='12' year='1974'/> <town>Leizig</town> <country>Germany</country> </xupdate:element> </xupdate:insert-before> </xupdate:modifications>
---update---
In XUpdate, document nodes are addressed using XPath 1.0 language. XPath by definition doesn't reflect default namespace. XPath can only address namespaced nodes if the namespace is associated with a prefix (in some implementations, a namespace prefix may be registered in the XPath engine). In XPath, it is not possible to adress <foo xmlns='bar'/> with /foo. One has to associate the "bar" namespace with a prefix first. XML::XUpdate::LibXML behavior is correct in this case (and consistent with both XUpdate and XPath 1.0 specifications). You may find the same behavior in XML::LibMXL and libxml2. Unfortunatelly, XUpdate working draft http://www.xmldb.org/xupdate/xupdate-wd.html#N326484 doesn't provide any means for registering namespace prefixes within the XUpdate document. The problem could be solved by providing a command line option to allow namespace prefix registration. This would IMO not break XUpdate WD conformance. I plan to make such command-line option available in the next version which is to be released soon. -- Petr Pajas