Hi to all,
I want to create a document with a namespace like this:
<AuditFile xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.00_01">
with this code:
writer.WriteStartElement("AuditFile");
writer.WriteAttributeString("xmlns", null, null, "urn:OECD:StandardAuditFile-Tax:PT_1.00_01");
But the environment tells me that I cannot redefine the prefix '' from '' to 'urn:OECD:StandardAuditFile-Tax:PT_1.00_01' inside the same tag of the initial element.
I found that
writer.WriteStartElement("AuditFile");
writer.WriteAttributeString("xmlns", "x", null, "urn:OECD:StandardAuditFile-Tax:PT_1.00_01");
gives no problem, but the output is like this:
<AuditFile xmlns:x="urn:OECD:StandardAuditFile-Tax:PT_1.00_01">
I found this information in "o'Reilly XML XSLT XPath Pocket Reference 2nd edition":
In Example 1.1, we scoped each tag with the OReilly name-space. Namespaces are declared using the
xmlns:something attribute, where something defines the prefix of the name-space. The attribute
value is a unique identifier that differentiates this namespace from all other namespaces; the use of a
URI is recommended. In this case, we use the O'Reilly URI
http://www.oreilly.com as the default
namespace, which should guarantee uniqueness. A namespace declaration can appear as an attribute
of any element, in which case the namespace remains inside that element's opening and closing tags.
Here are some examples:
<OReilly:Books xmlns:OReilly='http://www.oreilly.com'>
...
</OReilly:Books>
<xsl:stylesheet xmlns:xsl='http://www.w3.org'>
...
</xsl:stylesheet>