Re: XSLT - Resolving default namespace name at run time.

Discussion in 'XML' started by Dimitre Novatchev, Jul 26, 2003.

  1. Dimitre Novatchev, Jul 26, 2003
    #1
    1. Advertising

  2. > I want to assign a default namespace to my result tree but to derive
    > the namespace uri programmatically at run time(actually by extracting
    > a parameter from another XML file).


    Then use xsl:element.

    This transformation:

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:eek:utput omit-xml-declaration="yes" indent="yes"/>

    <xsl:param name="pDefNamespace" select="'my:defNamespace'"/>
    <xsl:template match="/">
    <xsl:element name="t" namespace="{$pDefNamespace}">
    <xsl:element name="child" namespace="{$pDefNamespace}"/>
    </xsl:element>
    </xsl:template>
    </xsl:stylesheet>

    when applied on any source.xml (ignored) produces this result:

    <t xmlns="my:defNamespace">
    <child/>
    </t>



    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL
    Dimitre Novatchev, Jul 26, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    5,124
  2. Marrow
    Replies:
    0
    Views:
    510
    Marrow
    Aug 15, 2003
  3. Jason Heyes
    Replies:
    1
    Views:
    448
    Woebegone
    Nov 19, 2004
  4. Pierre Yves
    Replies:
    2
    Views:
    481
    Pierre Yves
    Jan 10, 2008
  5. Andy
    Replies:
    9
    Views:
    2,203
    Peter Flynn
    Feb 3, 2011
Loading...

Share This Page