This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: namespace
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] namespace
- From: "cutlass" <cutlass at secure0 dot com>
- Date: Tue, 24 Jul 2001 10:06:16 +0100
- Cc: <arsal01 at hotmail dot com>
- References: <F91DiKBsuZ2K4xDh9vX00006f5e@hotmail.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
in their simplest incarnation namespaces allow mixing of xml vocabularies,
since XSLT is itself an xml vocabulary with its own namespace (xsl: is the
prefix
here is an example with plain xml below;
<aaa xmlns="http://test.org/test>" xmlns:testprefix =
"http://test.org/anothertest">
<testprefix:bbb></testprefix:bbb>
</aaa>
defines the base namespace ( ie; no prefix ) as http://test.org/test, the
xmlns:testprefix defines another namespace, so we have mixing, why is this
useful ?
lets look at a more complicated cutdown xslt example ( u can see the whole
template at http://www.exslt.org/str/functions/replace/index.html)
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="str exsl">
<xsl:template name="/">
</xsl:template>
</xsl:stylesheet>
with this the namespace with the prefix xsl: is our XSLT namespace
the others are namespaces used with the exslt effort.
namespaces are an efficient method for mixing vocabularies, ie i could
extract the value of elements with only a specific namespace.
namespaces are also used for binding functionality,
for example ( taken from http://www.dpawson.co.uk/xsl/sect4/N9723.html);
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:j="http://icl.com/java.util.Random"
exclude-result-prefixes="j"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/brands">
<html>
<head>
<title>Random</title>
</head>
<body>
<xsl:variable name="cars" select="count(car)"/>
There are <xsl:value-of select="$cars" /> car brands in the list.<br />
<br />
<xsl:variable name="R" select="j:new()" />
<xsl:variable name="r" select="ceiling(count(car) * j:nextDouble($R))" />
Selected car brand is: <xsl:value-of select="car[$r]" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
this namespace generates a random number by using, this isnt done by magic,
the parser ( in this case using a java function ) has to be able to get to
the java function.
here is another example
(http://www.exslt.org/math/functions/asin/index.html) which illustrates this
function binding to microsoft javascript ( notice the xmlns:msxsl=
definition ).
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:math="http://exslt.org/math"
extension-element-prefixes="math msxsl">
<msxsl:script language="JavaScript" implements-prefix="math">
<![CDATA[
function asin(arg){ return Math.asin(arg);}
]]>
</msxsl:script>
</xsl:stylesheet>
---------------------------------------------------------------
to answer your question there is no default namespace with xml, except those
that you define.
here is the SOAP spec, you will notice that there are a few SOAP namespaces,
though if i had to give an answer here it is
xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
http://www.w3.org/TR/SOAP/
here is a soap FAQ
http://www.develop.com/soap/soapfaq.htm#28
some illustrating links
http://www.zvon.org/xxl/NamespaceTutorial/Output/index.html
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d162e21
cheers, jim fuller
----- Original Message -----
From: "Lodhi, arsalan" <arsal01@hotmail.com>
To: <xsl-list@lists.mulberrytech.com>
Cc: <arsal01@hotmail.com>
Sent: Tuesday, July 24, 2001 6:12 AM
Subject: [xsl] namespace
> Hi,
>
> I've a very simple and basic question. What is actually a namespace that
we
> use in xml and soap - what is its role ?
>
> arsalan
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list