XML Name Space -- XML namespace

Source: Internet
Author: User
Tags xsl
 

This is a bit abstract, not easy to understand, and I have learned a little bit, but it is very remarkable. It brings us a lot of convenience in XML applications, the XML function has also been greatly improved, and I feel like it. Oh, there is something wrong with it. Don't laugh!
Before entering the subject, we will reference an example:

<Table>
<Tr>
<TD> apples </TD>
<TD> bananas </TD>
</Tr>
</Table>
In the above XML, it is a bit similar to the table function in HTML we have seen before. In fact, you can also think it is as simple as that;

<Table>
<Name> African coffee table </Name>
<Width> 80 </width>
<Long> 120 </length>
</Table>
In this XML, we describe the information of a table. In this way, if we put the two XML into an XML file, we will encounter a naming conflict, so there is name space.
XML namespace-the solution to the above problems:
I. Use a prefix to solve naming conflicts:
The above two files are changed to the following:

1 -- <H: tr>
<H: TD> apples <H: TD> bananas </H: tr>
</H: Table>

2 -- <F: Table>
<F: Name> African coffee table </F: Name>
<F: width> 80 </F: width>
<F: length> 120 </F: length>
</F: Table>

Can we clearly separate two different types of information? You can easily reference these two files through

2. Use namespaces to solve this problem:

1 -- <H: tr>
<H: TD> apples <H: TD> bananas </H: tr>
</H: Table>

2 --- <F: Table xmlns: F = "http://www.w3.org/TR/xsl">
<F: Name> African coffee table </F: Name>
<F: width> 80 </F: width>
<F: length> 120 </F: length>
</F: Table>

In the preceding example, in addition to the prefix, The xmlns attribute is used. xmlns is the abbreviation of XML name space.

Namespace properties: typically the declaration where the element begins to mark, in the format of xmlns: namespace-Prefix = "namespace" such as: xmlns: F = "http://www.w3.org/TR/xsl"

During the naming process, the URL-like stuff in the text does not actually make sense, but it is just a mark. well, today it's so much. How can we use it? It's still to be studied .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.