www.webdeveloper.com
Results 1 to 3 of 3

Thread: Mpeg7 xml and namespace

  1. #1
    Join Date
    May 2006
    Posts
    2

    Mpeg7 xml and namespace

    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:

    <?xml-stylesheet type="text/xsl" href="18.xsl"?>
    <Mpeg7 xmlns="urn:mpeg:mpeg7:schema:2001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mpeg7="urn:mpeg:mpeg7:schema:2001" xsi:schemaLocation="urn:mpeg:mpeg7:schema:2001 Mpeg7-2001.xsd">

    <!-- ================================= CONTENT DESCRIPTION ================================================= -->
    <Description xsi:type="CreationDescriptionType">

    <!-- ************** 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 ??

    Edit: if u want to see the full xml file u can se it here www.onk.dk/temp/source1.xml
    Last edited by onkelsatan; 05-23-2006 at 08:20 AM.

  2. #2
    Join Date
    May 2006
    Posts
    2
    Figured it out me self.
    the default and mpeg7 namespace have the same URI which apparently make them the same thing.

  3. #3
    Join Date
    Mar 2004
    Posts
    3,056
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles