Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

Empty namespace from template

Hi

I have a very simple template that I call that populates option elements, it works fine but also inserts empty namespaces's

The xslt creates a page that is XHTML 1.0 Transitional.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

I would like to understand why this is and how can I fix this.

<xsl:template name="forOptionsDown">
      <xsl:param name="maxOpt"/>
            <xsl:if test="$maxOpt &gt; 1">
                  <xsl:call-template name="forOptionsDown">
                        <xsl:with-param name="maxOpt" select="$maxOpt - 1"/>
                  </xsl:call-template>
            </xsl:if>
            <option value="{(($y + 1) - $maxOpt)}"><xsl:value-of select="(($y + 1) - $maxOpt)"/></option>
</xsl:template>

I'll appreciate any help in understanding this as I have had this happen a lot and would like to understand why.

Regards
Bill

0
Bill_Harrison
Asked:
Bill_Harrison
  • 2
1 Solution
 
Geert BormansCommented:
what do you mean with empty namespace?
I assume
xmlns=""

That happens because you are creating an element in the null namespace
and the element in which you create this has a default namespace other than the null namespace
so there is no other option for the processor for undoing the namespace but adding an xmlns=""

you need to create this element in the same namespace of its parent
something like this
<option xmlns="http://www.w3.org/1999/xhtml" value="{(($y + 1) - $maxOpt)}"><xsl:value-of select="(($y + 1) - $maxOpt)"/></option>
0
 
Bill_HarrisonAuthor Commented:
Thanks Gertone

I think I understand now, that really helps.

Much appreciated.
0
 
Geert BormansCommented:
welcome
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now