Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » Connexions Tutorial and Reference » Combining XML Languages

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • CNX Documentation display tagshide tags

    This collection is included inLens: Connexions Documentation
    By: Connexions

    Comments:

    "The canonical how-to guide to using Connexions."

    Click the "CNX Documentation" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Combining XML Languages

Module by: Sarah Coppin, Brent Hendricks, Connexions. E-mail the authors

Summary: This module explains how to use XML namespaces and DTDs to combine multiple XML languages in the same document.

XML allows you to create documents in custom markup languages. But what if you want to combine markup from multiple languages in the same document? What if there are one or more tags that exist in both languages, but with different meanings? You could, for example, have a <table> tag in HTML and one in a language describing office furniture as well. How do you use these tags unambiguously, without losing functionality?

The solution is to use an extension to XML called namespaces (See the W3C's recommendation, Namespaces in XML). A namespace associates a unique global identifier (usually a URI) with a particular set of tags and their usage rules. To declare a namespace for a particular tag, set the xmlns attribute to the value of the unique identifier.

You can also define a namespace prefix for use in your document. To do this, use a modified version of the xmlns attribute. For example, you would use the attribute xmlns:foo="http://somewhere.org/foo" to associate the prefix foo with the namespace identifier http://somewhere.org/foo. You can then indicate which tags come from that namespace by adding the appropriate prefix to each tag. Thus, the bar tag in foo's namespace would be written as <foo:bar> and </foo:bar>.

When you use the default namespace any children of that tag lacking an explicit prefix will be assumed to have come from the same namespace. This allows you to define a default namespace for all of the children of a tag. This is especially useful when used on the root node, which is the outermost tag in a document.

Example 1

For CNXML 0.6 there is only one schema. The document tag will contain the namespace for all available languages and will look like this:


    <document xmlns="http://cnx.rice.edu/cnxml"
              xmlns:md="http://cnx.rice.edu/mdml/0.4"
              xmlns:bib="http://bibtexml.sf.net/"
              xmlns:m="http://www.w3.org/1998/Math/MathML"
              xmlns:q="http://cnx.rice.edu/qml/1.0"
              id="new"
              cnxml-version="0.6"
              module-id="new">
      

Collection Navigation

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks