remove

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • N9

    remove

    Hi

    I had a xslt that parse a XML document, output is HTML

    But XSLT adding not valid code:
    <ul class="level_1" xmlns="" xmlns:xsi="http ://www.w3.org/2001/
    XMLSchema-instance">


    I had try to adding the text below to stylesheet but it does't help.

    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" exclude-result-
    prefixes="xsi"

    do any help me ?

    Best regards

    //N9
  • Martin Honnen

    #2
    Re: remove

    N9 wrote:
    I had a xslt that parse a XML document, output is HTML
    >
    But XSLT adding not valid code:
    <ul class="level_1" xmlns="" xmlns:xsi="http ://www.w3.org/2001/
    XMLSchema-instance">
    Show us the relevant XML input and the stylesheet, then we can help
    improve the stylesheet.


    --

    Martin Honnen

    Comment

    • N9

      #3
      Re: remove

      Hi

      Here is my xslt.

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/
      Transform">
      <xsl:output omit-xml-declaration="ye s" encoding="utf-8"
      method="html" indent="no"/>

      <xsl:variable name="firstMenu ItemClass">firs t </xsl:variable>
      <xsl:variable name="lastMenuI temClass">last </xsl:variable>
      <xsl:variable name="selectedM enuItemClass">s elected </xsl:variable>
      <xsl:variable name="expandedM enuItemClass">e xpanded </xsl:variable>
      <xsl:variable name="hasChildr enMenuItemClass ">hasChildr en </
      xsl:variable>



      <xsl:variable name="FilenameP refix">
      <xsl:value-of select="Navigat ion/@FilenamePrefix "/>
      </xsl:variable>
      <xsl:variable name="FileExten sion">
      <xsl:value-of select="Navigat ion/@FileExtension"/>
      </xsl:variable>
      <xsl:variable name="SelectedP ageId">
      <xsl:value-of select="Navigat ion/@PageId"/>
      </xsl:variable>
      <xsl:template match="Module" xml:space="defa ult">

      <xsl:choose>
      <xsl:when test="Name='Sit emap'">
      <div id="sitemap"><x sl:apply-templates select="Layout" /></div>
      </xsl:when>
      <xsl:otherwis e>
      <xsl:copy-of select="Layout"/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:template>

      <xsl:template match="Module">
      <xsl:apply-templates select="Layout/Row" />
      </xsl:template>
      <xsl:template match="Layout/Row">
      <xsl:apply-templates select="Cell[@Id='2']"/>
      </xsl:template>
      <xsl:template match="Cell">
      <xsl:copy-of select="Content Area/node()"/>
      </xsl:template>
      <xsl:template match="ContentA rea"><xsl:copy-of select="node()"/></
      xsl:template>
      <xsl:template match="Navigati on" xml:space="defa ult">
      <xsl:if test="Navigatio nElement[@ShowInNavigati on='true']">
      <ul>
      <xsl:attribut e name="class"><x sl:text/>level_<xsl:val ue-of
      select="number( NavigationEleme nt/@Level)+1" /></xsl:attribute>

      <xsl:apply-templates
      select="Navigat ionElement[@ShowInNavigati on='true']"/>
      </ul>
      </xsl:if>
      </xsl:template>
      <xsl:template match="Navigati onElement[@ShowInNavigati on='true']"
      xml:space="defa ult">
      <xsl:variable name="itemClass ">
      <xsl:if test="position( ) = 1">
      <xsl:value-of select="$firstM enuItemClass" disable-output-
      escaping="yes"/>
      </xsl:if>
      <xsl:if test="position( ) = last()">
      <xsl:value-of select="$lastMe nuItemClass" disable-output-
      escaping="yes"/>
      </xsl:if>
      <xsl:if test="@Selected ='true'">
      <xsl:value-of select="$select edMenuItemClass " disable-output-
      escaping="yes"/>
      </xsl:if>
      <xsl:if test="@ChildSel ected='true'">
      <xsl:value-of select="$expand edMenuItemClass " disable-output-
      escaping="yes"/>
      </xsl:if>
      <xsl:if test="@NumberOf Children &gt; '0'">
      <xsl:value-of select="$hasChi ldrenMenuItemCl ass" disable-
      output-escaping="yes"/>
      </xsl:if>
      </xsl:variable>

      <xsl:choose>

      <xsl:when test="@PageId=3 39"><li class="fagfolk" >Specielt for
      fagfolk</li></xsl:when>

      <xsl:when test="@PageId=5 40"><li class="fagfolk" >Specielt for
      fagfolk</li></xsl:when>

      <xsl:when test="@PageId=8 92"><li class="fagfolk" >Specielt for
      fagfolk</li></xsl:when>

      <xsl:when test="@PageId=8 93"><li class="fagfolk" >Specielt for
      fagfolk</li></xsl:when>
      </xsl:choose>

      <li>
      <xsl:if test="not($item Class='')">
      <xsl:attribut e name="class">
      <xsl:copy-of select="normali ze-space($itemClas s)"/>
      </xsl:attribute>
      </xsl:if>
      <a>
      <xsl:if test="not($item Class='')">
      <xsl:attribut e name="class">
      <xsl:copy-of select="normali ze-space($itemClas s)"/>
      </xsl:attribute>
      </xsl:if>
      <xsl:attribut e name="href" xml:space="defa ult">
      <xsl:choose>
      <xsl:when test="LongUrl != ''">/<xsl:value-of
      select="LongUrl " disable-output-escaping="yes"/></xsl:when>
      <xsl:otherwis e>/<xsl:value-of select="$Filena mePrefix"/
      ><xsl:value-of select="@PageId "/><xsl:value-of select="$FileEx tension"/
      ></xsl:otherwise>
      </xsl:choose>
      </xsl:attribute>
      <xsl:value-of select="Navigat ionTitle" disable-output-
      escaping="yes"/>
      </a>
      <xsl:if test="Navigatio nElement[@ShowInNavigati on='true']">
      <ul>
      <xsl:attribut e name="class"><x sl:text/>level_<xsl:cop y-of
      select="number( NavigationEleme nt/@Level)+1"/></xsl:attribute>

      <xsl:apply-templates
      select="Navigat ionElement[@ShowInNavigati on='true']"/>
      </ul>
      </xsl:if>
      </li>
      </xsl:template>
      <xsl:template match="*" />
      </xsl:stylesheet>


      Comment

      • Joseph J. Kesselman

        #4
        Re: remove

        But XSLT adding not valid code:
        <ul class="level_1" xmlns="" xmlns:xsi="http ://www.w3.org/2001/
        XMLSchema-instance">
        to remove that default).

        If the problem is that you're trying to validate against a DTD which
        doesn't allow those namespace declarations... well, DTDs are really not
        fully compatable with namespaced documents, for just this sort of
        reason. You can modify the DTD to allow namespace declarations to appear
        anywhere, but since prefixes may change you can't really write a DTD
        which will completely cover the possibilities.

        Switching to schemas will solve that problem.

        Meanwhile. you may be able to reduce the namespace declarations by
        avoiding situations such as this one where the default namespace and/or
        other prefixes are being redefined in the middle of the document. (The
        reason it generated the xmlns= is that you were in a default namespace
        context and then tried to output a non-namespaced <ulelement.) It's
        also possible to tell XSLT not to output namespaces which aren't being
        used, which may help if the xsi: is being copied when you didn't intend
        it to be.

        Comment

        • Martin Honnen

          #5
          Re: remove

          N9 wrote:
          Here is my xslt.
          Show us a minimal but complete XML input document too that allows us to
          reproduce the problem.


          --

          Martin Honnen

          Comment

          Working...