Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] removing namespaces

From: Abel Braaksma <abel.online@--------->
To:
Date: 4/1/2008 6:53:00 PM
I'm not totally sure of what you mean by "hiding" a namespace, which is 
impossible. Either you remove it (which means you change the QName of 
the elements) or you leave it in. Cleaning up namespaces (putting there 
declarations on top of the XML) is possible by declaring the namespaces 
in the xsl:stylesheet declaration element (and I'm sure there are other 
ways, but I believe that's the way I did it). Then, all you need to do 
is use the prefixes in your element names:



<xsl:element name="myns:method">.... etc



using an AVT is also ok, as long as it resolves to an existing namespace.



Btw, your code is not complete and as it is, it is a bit misty for me 
why it creates the output you say it does (you do not show declarations 
for prefixes "scrcml" and "srcml-new" which are the ones you wanted out 
of your way because they were not used in all elements, right?).



Anyway, bottom line is: often it is easiest to declare namespaces as 
early as you can so that you have a clearer document to read.



Cheers,
-- Abel Braaksma





Garvin Riensche wrote:
Hello,



One more namespaces question:



I have this template:



<xsl:template name="addMethod">
  <xsl:element name="method" namespace="http://new.element">
    <xsl:attribute name="name" select="$method_name"/>
    <xsl:attribute name="id" select="$method_id"/>
    <modifiers>
      <modifier name="{$modifier}"/>
    </modifiers>
    <type name="{$type}"/>
    <block>
      <expr>
        <return>
      <expr>
        <identifier name="{$variable_name}" idref="{$variable_id}"/>
      </expr>
    </return>
      </expr>
    </block>
  </xsl:element>
</xsl:template>

which produces the following output:



<method xmlns="http://new.element" name="get_j" id="MB1;get_j()">

  <modifiers xmlns:srcml-new="http://new.element" xmlns="">

    <modifier name="public"/>

  </modifiers>

  <type xmlns:srcml="http://srcml.de"

        xmlns:srcml-new="http://new.element" xmlns=""

        name="int"/>

  <block xmlns:srcml="http://srcml.de"    
        xmlns:srcml-new="http://new.element" xmlns="">

    <expr>

       <return>

          <expr>

             <identifier name="j" idref="VCB1;#Cint;j;"/>

          </expr>

       </return>

    </expr>

  </block>

</method>



How do I hide the namespaces of the elements? Is the only possibility 
to add several xsl:exclude-result-prefixes="..." to the "modifiers", 
"type" and "block" elements? Or is there another solution?



regards,
Garvin


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent