Im currently working with an Mpeg7 xml file and want to preform some 'selections' via. xpath.
However im a bit confused about the namespace applied to the elements in the xml file.
Here is the beginning of the xml file:
<!-- ************** MOVIE NUMBER 1 ************************ -->
<CreationInformation>
<Creation>
.....
...
..
Im not an expert at all but if i remember correct and xmlns without any prefix sets the default namespace which scope applies to all sub / descendent elements. So if elements are declared without any prefix they should belong to the default namespace which of couse dont have any prefix.
However in the mpeg7 xml file example it seem to be a little different. The Mpeg7 element declares a default namespace plus some others.
All the elements (such as Mpeg, Description, CreationInformation, Creation ...) within the Mpeg7 element (which sets all the namespaces) are not declared with any prefix and should belong to the default prefix.
So first when I wanted to make an xpath i did /Mpeg7/Description/CreationInformation but what happend ?? nothing. By trial and error I discovered that for some reason all these elements belong to the mpeg7 namespace. So for the Xpath to work i must do /mpeg7:Mpeg7/mpeg7escription/mpeg7:CreationInformation
Can anyone tell me how the mpeg7 namespace is connected to the elements that have not been declared with an mpeg7:Element prefix ??
Yup. Just to clarify though: When you declare a default namespace on an element, only elements that element and descendants of that element default to the namespace provided if no namespace prefix has been used. It doesn't mean that default namespace is applied to any element in the document. It is common to specify a default namespace on the document element, but you can declare them on any element.
Bookmarks