Note that there are some explanatory texts on larger screens.

plurals
  1. POConfiguring an XML Namespace
    text
    copied!<p>I have made an XML generator with a few different options, one is a style option which defines whether to use attributes or elements for primitive data types. </p> <p>XML schemas aren't supported right now, but I need to allow the setup of an XML Namespace, and I have been doing some research. My understanding is the XML namespace can have a prefix, but it doesn't have to. It also needs a unique string attribute value that is <strong>usually</strong> a URI, but doesn't have to be.</p> <p>I am a little bit confused, as I am new to XML namespaces, and I have a few questions about this, if we take a look at an example xml document</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;root xmlns="some_identifier"&gt; &lt;oneKey&gt;value&lt;/oneKey&gt; &lt;/root&gt; </code></pre> <p>This is using an element style of the key value example, and I'm going to allow the configuration of "some_identifier". In this example is the "oneKey" element under the XML namespace? Or do I have to specify a prefix like <code>xmlns:ns</code> and then prefix "oneKey" with "ns"? </p> <p>Also if we take a look at attribute style:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;root xmlns="some_identifier" oneKey="value" /&gt; </code></pre> <p>Do we need to define a similar prefix in oneKey in this example?</p> <p>I apologize if I'm way off the mark in these questions, please let me know if I'm just not making sense,</p> <p>UPDATE:</p> <p>I have found this site: <a href="http://www.rpbourret.com/xml/NamespacesFAQ.htm#exec_1" rel="nofollow">http://www.rpbourret.com/xml/NamespacesFAQ.htm#exec_1</a></p> <p>That says these two are identical:</p> <pre><code>&lt;foo:A xmlns:foo="http://www.foo.org/"&gt; &lt;foo:B&gt;abcd&lt;/foo:B&gt; &lt;/foo:A&gt; </code></pre> <p>and</p> <pre><code>&lt;A xmlns="http://www.foo.org/"&gt; &lt;B&gt;abcd&lt;/B&gt; &lt;/A&gt; </code></pre> <p>which is very useful, but regarding the attribute style. Do I need to prefix attributes? Or will the xmlns default work for these as well?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload