Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: namespace crash course #27662

Merged
merged 10 commits into from
Jul 1, 2023
Merged

Update: namespace crash course #27662

merged 10 commits into from
Jul 1, 2023

Conversation

estelle
Copy link
Member

@estelle estelle commented Jun 29, 2023

  • Made API links internal instead of pointing to spec
  • Grammar updates
  • Namespaces are now implied in mathML, SVG, and HTML
  • change XHTML to HTML
  • removed some future-tensing as this doc was super old.

Only added a single link to CSS namespace API. after namespace documentation is complete will add a few more links, but that is a future PR

@estelle estelle requested review from a team and Ryuno-Ki and removed request for a team June 29, 2023 21:06
@github-actions github-actions bot added the Content:SVG SVG docs label Jun 29, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 29, 2023

Preview URLs

Flaws (1)

URL: /en-US/docs/Web/SVG/Namespaces_Crash_Course
Title: Namespaces crash course
Flaw count: 1

  • broken_links:
    • Can't resolve /en-US/Docs/Web/CSS/CSS_namespaces/
External URLs (5)

URL: /en-US/docs/Web/SVG/Namespaces_Crash_Course
Title: Namespaces crash course

(comment last updated: 2023-07-01 18:35:27)


Note that namespace names are just strings, so the fact that the SVG namespace name also looks like a URI isn't important. URIs are commonly used because they are unique, the intention is not to "link" somewhere. (In fact URIs are used so frequently that the term "namespace URI" is commonly used instead of "namespace name".)
Note that namespace names are just strings, so the fact that the SVG namespace name also looks like a URI isn't important. URIs are commonly used because they are unique, the intention is not to "link" somewhere. (In fact, URIs are used so frequently that the term "namespace URI" is commonly used instead of "namespace name".)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know that! I'd always wondered why rendering worked even if there was no fetch on the namespace URL.

@@ -64,11 +66,11 @@ XML dialects not only define their own elements, but also their own parameters.
</svg>
```

This example has the rather unusual looking parameter `xmlns:xlink`. As you may guess from the first 'xmlns' part, this is another namespace declaration. However, instead of setting the default namespace, this namespace declaration sets the namespace for something called a "namespace prefix". In this case, we have chosen to use the prefix `xlink` (the second part) since the prefix will be used to tell the user agent about attributes that belong to XLink.
This example has the rather unusual-looking parameter `xmlns:xlink`. As you may guess from the first `xmlns` part, this is another namespace declaration. However, instead of setting the default namespace, this namespace declaration sets the namespace for something called a "[namespace prefix](/en-US/docs/Web/API/CSSNamespaceRule/prefix)". In this case, we have chosen to use the prefix `xlink` (the second part) since the prefix will be used to tell the user agent about attributes that belong to `XLink`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FWIW, the namespace prefix link to a css rule on an SVG example looks a bit odd when reading the source. My assumption is that you chose this link and it makes sense to a reader.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this weird too, especially since the prefix page is very brief as well.


As their name suggests, namespace prefixes are used to prefix parameter and element names. This is done by putting the namespace prefix and a colon before the parameter name as shown on the `<script>` element in the example above. This tells the user agent that the particular parameter belongs to the namespace assigned to the namespace prefix (XLink), and is a parameter that can be used with the same meaning on other elements.
As their name suggests, namespace prefixes are used to prefix parameter and element names. This is done by putting the namespace prefix and a colon before the parameter name as shown on the `<script>` element in the example above. This tells the user agent that the particular parameter belongs to the namespace assigned to the namespace prefix (`XLink`), and is a parameter that can be used with the same meaning on other elements.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the "same meaning on other elements"? I understand that it is the same name, just confirming that if the same name is used in multiple specs it means the same thing.

Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so much better. I've added some nits/suggestions. Approving so you can merge after whatever you choose to accept or not.


#### Redeclaring the default namespace

So if all the descendants of the root element are also defined to be in the default namespace, how do you mix in content from another namespace? Easy. You just redefine the default namespace. Here's a short example.
If all the descendants of the root element are also defined to be in the default namespace, how do you mix in content from another namespace? You redefine the default namespace! Here's a short example.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You redefine the default namespace!

In HTML, now the default namespaces are always implied and they are forced (you can't declare your own default namespace in the markup). So this entire section, from HTML point of view, has no utility left.
All it is doing now is asking developers to explicitly use xmlns attributes, which is not required.

I say we either

  • remove the section Redeclaring the default namespace completely
  • or make it discuss about XML, where it still applies:
      <report xmlns="www.acme.org/reports>
          <title>Some stats</title>
          <summary>...</summary>
    
          <statTable xmlns="www.acme.org/tables>
                <content>...</content>
                <summary xmlns="www.acme.org/reports">...</summary> <!-- redeclaring root's default namespace -->
         </statTable>
      </report>

On MDN do we consider XML while discussing CSS? or just HTML?

estelle and others added 2 commits June 30, 2023 16:15
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>

See, namespaces really aren't that hard.
This example was for illustrative purposes only. With HTML, `http://www.w3.org/1999/xhtml` is the implied namespace. It does not need to be explicitly declared.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This example was for illustrative purposes only. With HTML, `http://www.w3.org/1999/xhtml` is the implied namespace. It does not need to be explicitly declared.
This example was for illustrative purposes only. With HTML, `http://www.w3.org/1999/xhtml` is the implied namespace. It does not need to be explicitly declared. In HTML, the default namespaces are always implied and are forced, meaning you can't redeclare a different default namespace in the markup

files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
Copy link
Contributor

@OnkarRuikar OnkarRuikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing lint issues.

files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar suggestions

files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
files/en-us/web/svg/namespaces_crash_course/index.md Outdated Show resolved Hide resolved
estelle and others added 6 commits July 1, 2023 11:31
Co-authored-by: Onkar Ruikar <87750369+OnkarRuikar@users.noreply.github.com>
Co-authored-by: Onkar Ruikar <87750369+OnkarRuikar@users.noreply.github.com>
Co-authored-by: Onkar Ruikar <87750369+OnkarRuikar@users.noreply.github.com>
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
@estelle estelle merged commit 69f7d8a into mdn:main Jul 1, 2023
@estelle estelle deleted the namespaces_crash_course branch August 3, 2023 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:SVG SVG docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants