xml - namespace in xslt placed in root tag -


i have xslt in have defined function. transformer says function must have it's namespace, declared dummy namespace in head of xslt, namespace appears in root tag of output! can't guess how avoid this...

example:

input.xml

<something>      <mytag> test </mytag> </something> 

test.xsl

<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fn="http://function" version="2.0" >     <xsl:output method="xml" indent="yes" />    <xsl:function name="fn:trim" >     <xsl:param name="pstr"/>     <xsl:value-of select="replace($pstr,'^\s*(.+?)\s*$', '$1')"/>   </xsl:function>    <xsl:template match="something">     <root><xsl:value-of select="fn:trim(mytag)" /></root>   </xsl:template> </xsl:stylesheet> 

out.xml

<?xml version="1.0" encoding="utf-8"?> <root xmlns:fn="http://function">test</root> 

it's xmlns:fn="http://function" in <root> tag i'd remove output. doesn't know if matter, i'm using saxon-he-9.4.

simply add <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fn="http://function" version="2.0" exclude-result-prefixes="fn">. note fn used xpath function namespace might want use different prefix avoid confusion users of code.


Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

java - What is the equivalent of @Value in CDI world? -