XSL - Include Variable as namespace

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #1

    XSL - Include Variable as namespace

    Hi,

    I know this is a common issue, but to be honest all the sites I find with solutions to this dont explain it well at all.

    I have a variable ($fileName) which I want to add to

    The autumn equinox marks a turning point in the No


    then attach .xsd to the end

    to make http://tempuri.org/contentsofvariable.xsd

    and include this in a namespace called xmlns (with no : suffix)

    e.g
    <AnswerList xmlns="http://tempuri.org/070905Assessmen t_RESCO_Schema. xsd">

    As this is how an app needs this file.

    I do not understand the usage of the namespace:alias thing, or the copy-of things, if someone knew how to do this and would explain it in context that would be amazing.

    the variable filename contains the filename (without ".xsd")

    AnswerList is created like this

    Code:
    <xsl:element name="AnswerList">
    ... content
    </xsl:element>
    I have tried things like

    Code:
    <xsl:variable name="myNS">
    	<xsl:text>http://tempuri.org/</xsl:text>
    	<xsl:value-of select="$fileName"/>
    	<xsl:text>.xsd</xsl:text>
    </xsl:variable>
    
    <xsl:element name="AnswerList" namespace="$myNS">
    but they have not worked.

    Thanks for any help!

    Cheers,

    Mark
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    ...or if anyone even knows a clear/easy to explain tutorial/explanation for this could they just post a URL!

    Cheers folks,

    Mark

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      Use braces
      <xsl:element name="AnswerLis t" namespace="{$my NS}">

      Comment

      • markmcgookin
        Recognized Expert Contributor
        • Dec 2006
        • 648

        #4
        Originally posted by jkmyoung
        Use braces
        <xsl:element name="AnswerLis t" namespace="{$my NS}">
        Awesome!

        That's worked brilliantly!

        Cheers!

        Comment

        Working...