XML Namspaces

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chase Preuninger

    XML Namspaces

    What did I do wrong?

    <?xml version="1.0"?>
    <rfs:filesyst em xmlns:rfs="http ://www.somewebpage .com/rfs"/>
    <rfs:root>
    <rfs:attr key="name" value="c:\"/>
    <rfs:folder>
    <rfs:attr key="name" value="Users"/>
    <rfs:file>
    <rfs:attr key="name" value="pic.jpg"/>
    <rfs:attr key="size" value="5675675"/>
    <rfs:attr key="lastmod" value="53595735 79797693"/>
    </rfs:file>
    <rfs:folder>
    <rfs:attr key="name" value="Chase"/>
    <rfs:attr key="compressed " value="true"/>
    <rfs:file>
    <rfs:attr key="name" value="config.s ys"/>
    <rfs:attr key="size" value="5678"/>
    <rfs:attr key="execute" value="false"/>
    </rfs:file>
    </rfs:folder>
    </rfs:folder>
    </rfs:root>
    </rfs:filesystem>
  • Chase Preuninger

    #2
    Re: XML Namspaces

    also, sorry I spelled namespaces wrong

    Comment

    • David Carlisle

      #3
      Re: XML Namspaces

      Chase Preuninger wrote:
      What did I do wrong?
      >
      <?xml version="1.0"?>
      <rfs:filesyst em xmlns:rfs="http ://www.somewebpage .com/rfs"/>
      the above is an empty element ending with /so the XML file
      ends there, and any following XML elements are in error.
      presumably you wanted there not />

      David

      <rfs:root>
      <rfs:attr key="name" value="c:\"/>
      <rfs:folder>
      <rfs:attr key="name" value="Users"/>
      <rfs:file>
      <rfs:attr key="name" value="pic.jpg"/>
      <rfs:attr key="size" value="5675675"/>
      <rfs:attr key="lastmod" value="53595735 79797693"/>
      </rfs:file>
      <rfs:folder>
      <rfs:attr key="name" value="Chase"/>
      <rfs:attr key="compressed " value="true"/>
      <rfs:file>
      <rfs:attr key="name" value="config.s ys"/>
      <rfs:attr key="size" value="5678"/>
      <rfs:attr key="execute" value="false"/>
      </rfs:file>
      </rfs:folder>
      </rfs:folder>
      </rfs:root>
      </rfs:filesystem>

      --

      Comment

      • Chase Preuninger

        #4
        Re: XML Namspaces

        I also don't get what the purpose of the xmlns is

        Comment

        • Joseph J. Kesselman

          #5
          Re: XML Namspaces

          Chase Preuninger wrote:
          I also don't get what the purpose of the xmlns is
          Sounds like you need a basic education in what XML Namespaces are.
          Reading a good modern XML tutorial might be worthwhile at this point. (I
          usually point folks to the articles and tutorials at
          http://www.ibm.com/xml, but I admit I'm biased.)

          For info specifically about XML Namespaces, see James Clark's description at

          or the official (but somewhat harder to read) definition at

          Comment

          • Chase Preuninger

            #6
            Re: XML Namspaces

            I have I big book on XML, I just never really got the entire thing
            about the xmlns.

            Comment

            • Joseph J. Kesselman

              #7
              Re: XML Namspaces

              Chase Preuninger wrote:
              I have I big book on XML, I just never really got the entire thing
              about the xmlns.
              Namespaces are a way of managing XML-based grammars so they can be
              reliably recognized by applications, and if necessary intermixed in a
              single document. The xmlns attributes are used to bind prefixes (which
              are just "syntactic sugar" shorthand) to the namespace names (strings
              formatted as absolute URI references). Those bindings are scoped, so the
              same prefix may mean different URIs in different parts of the program.
              It's also possible to set up a default namespace for elements in one of
              those parts, just to save a bit of typing. (This sometimes improves
              readabilty, sometimes makes it worse.)

              The namespace names are formatted as URI references because "we already
              know how to manage those so they won't conflict with each other." And
              that's all there is to that. The namespace name has no other built-in
              meaning beyond being the name for this namespace. There is no guarantee
              that there is anything meaningful behind that URI if you try to
              dereference it, or what you might find there if anything is present.
              Basically, you shouldn't be trying. (The Semantic Web folks said they
              would come up with a standard for what a namespace URI might point to. I
              haven't heard any concrete proposals, and it's been several years. Don't
              hold your breath.)

              So namespaces are just an alternative to having to always type a
              <gawdaful_long_ name_that_you_h ope_nobody_else _used/>. That really is all
              there is to them.


              Most modern XML standards assume you're working with namespaced
              documents. XML Schema, XPath, XSLT, the Semantic Web stuff, XHTML,
              XQuery, and so on all assume namespaces are a prerequisite.

              Read some tutorials and/or re-read that section of the book -- or find
              another document which explains this better.

              Comment

              • Chase Preuninger

                #8
                Re: XML Namspaces

                Does the xmlns attribute need to have a URI or could it just contain
                anything?

                Comment

                • Joseph J. Kesselman

                  #9
                  Re: XML Namspaces

                  Chase Preuninger wrote:
                  Does the xmlns attribute need to have a URI or could it just contain
                  anything?
                  A "namespace name" must conform to the syntax of an Absolute URI
                  Refrence -- an absolute URI possibly followed by a fragment identifier.

                  If you really mean the xmlns attribute (xmlns=, as opposed to
                  xmlns:foo=), that's the default namespace declaration. Same restriction
                  on its value.

                  Comment

                  Working...