[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] Quiz: how many namespaces are in scope?
- From: David <dlee@calldei.com>
- To: xml-dev@lists.xml.org
- Date: Mon, 30 Aug 2010 15:57:50 -0400
I dont belive thats teh same thing as saying there are 21 'namespace
nodes'
The question being answered by
$ xpath++ "count(//namespace::*)" nlist.xml
Is (IMHO)
SUM (
For each Node
Count the number of active namespace declarations
)
Well maybe its pedantic asking of thast a unique 'node' or not.
On 8/30/2010 3:50 PM, Hermann Stamm-Wilbrandt wrote:
>> Lesson Learned: Implicit on the root element of every XML document is
> this namespace declaration:
>
>> <root xmlns:xml="http://www.w3.org/XML/1998/namespace">
>
> 1) Not sure about "Implicit on the root element" (xpath++ from [1]):
> $ xpath++ "count(//namespace::*)" nlist.xml
> 21
> $ xpath++ "count(/namespace::*)" nlist.xml
> 0
> $ xpath++ "count(//*)" nlist.xml
> 7
> $ xpath++ "count(/|//*)" nlist.xml
> 8
> $ xpath++ "count(/*/namespace::*)" nlist.xml
> 3
> $
>
>
> 2) The implicit xml namespace declaration was the reason for
> " and name()!='xml' " in this XML serialization ([2]).
>
> <xsl:for-each select="namespace::*">
> <xsl:if test="not(.=../../namespace::*) and name()!='xml'">
> <xsl:value-of select= "concat(' xmlns',
> substring(':',1 div boolean(name
> ())),
> name(),'="',.,'"')" />
> </xsl:if>
> </xsl:for-each>
>
>
>
> [1]
> https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14455521�
> [2]
> http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201008/msg00186.html
>
> Mit besten Gruessen / Best wishes,
>
> Hermann Stamm-Wilbrandt
> Developer, XML Compiler, L3
> WebSphere DataPower SOA Appliances
> ----------------------------------------------------------------------
> IBM Deutschland Research& Development GmbH
> Vorsitzender des Aufsichtsrats: Martin Jetter
> Geschaeftsfuehrung: Dirk Wittkopp
> Sitz der Gesellschaft: Boeblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294
>
>
>
>
> From: "Costello, Roger L."<costello@mitre.org>
> To: "xml-dev@lists.xml.org"<xml-dev@lists.xml.org>
> Date: 08/30/2010 08:00 PM
> Subject: [xml-dev] Quiz: how many namespaces are in scope?
>
>
>
> Hi Folks,
>
> Consider this XML document:
>
> <?xml version="1.0"?>
> <N1:NumberList xmlns:N1="http://www.example1.org"
> xmlns:N2=" http://www.example2.org ">
> <Number>23</Number>
> <Number>41</Number>
> <Number>70</Number>
> <Number>103</Number>
> <Number>99</Number>
> <Number>6</Number>
> </N1:NumberList>
>
> For the first child element:
>
> <Number>23</Number>
>
> what namespaces are in scope?
>
> I created an XSLT template to output the<Number> element's in-scope
> namespaces:
>
> -------------------------------------------
> <xsl:template match="*">
> <xsl:for-each select="namespace::*">
> <xsl:value-of select="."/></p>
> </xsl:for-each>
> </xsl:template>
> -------------------------------------------
>
> Here is the output:
>
> http://www.w3.org/XML/1998/namespace
>
> http://www.example1.org
>
> http://www.example2.org
>
> There are three (3) in-scope namespaces.
>
> Lesson Learned: Implicit on the root element of every XML document is this
> namespace declaration:
>
> <root xmlns:xml="http://www.w3.org/XML/1998/namespace">
>
> NOTE: it is illegal to explicitly declare the xml namespace. The xml
> namespace is built into every XML application.
>
> Since the xml namespace is implicitly declared in every XML document, you
> can immediately use the xml:lang attribute and the xml:space attribute,
> e.g.,
>
> <movie>
> <title>The Laughing Cow</title>
> <title xml:lang="fr">La Vache Qui Rit</title>
> </movie>
>
> Here is an XSLT template to output the in-scope namespaces and their
> prefixes:
>
> -------------------------------------------
> <xsl:template match="*">
> <xsl:for-each select="namespace::*">
> Namespace in scope =<xsl:value-of select="."/>
> Namespace prefix =<xsl:value-of select="name(.)"/>
> </xsl:for-each>
> </xsl:template>
> -------------------------------------------
>
> Here is the output:
>
> Namespace in scope = http://www.w3.org/XML/1998/namespace
> Namespace prefix = xml
>
> Namespace in scope = http://www.example1.org
> Namespace prefix = N1
>
> Namespace in scope = http://www.example2.org
> Namespace prefix = N2
>
> QUESTIONS
>
> 1. Have I correctly analyzed the situation (regarding in-scope namespaces)?
>
> 2. What else would you add?
>
> /Roger
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>
>
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
--
David A. Lee
dlee@calldei.com
http://www.xmlsh.org
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]