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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -