I'm learning XSL and hope to get some help. I want to extract part of the following datasets.xml and output them as tab delimited texts:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<listDatasetsResponse xmlns="http://www.algorithmics.com/schema">
<status>OK</status>
<datasets size="31">
<dataset>
<id>stress_20150910_20150910_160259</id>
<basedOn>Mimm_20150910_20150910_030922</basedOn>
<active>false</active>
<sandbox>true</sandbox>
<ownedBy>admin</ownedBy>
<createdOn>2015-09-10T16:04:24.199-04:00</createdOn>
<createdBy>rtcesupp</createdBy>
<evaluated>true</evaluated>
<stopped>false</stopped>
</dataset>
<dataset>
<id>imm_20150910_20150910_140315</id>
<basedOn>Mimm_20150910_20150910_030922</basedOn>
<active>true</active>
<sandbox>true</sandbox>
<ownedBy>admin</ownedBy>
<createdOn>2015-09-10T14:04:42.696-04:00</createdOn>
<createdBy>rtcesupp</createdBy>
<evaluated>true</evaluated>
<stopped>false</stopped>
</dataset>
</datasets>
</listDatasetsResponse>
here is the XSL I used:
$ vi dataset.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="iso-8859-1"/>
<xsl:strip-space elements="*" />
<xsl:template match="/listDatasetsResponse/datasets/dataset">
<xsl:value-of select="id"/><xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="active='true'">
<xsl:text>ACTIVE</xsl:text>
</xsl:when>
<xsl:when test="stopped='true'">
<xsl:text>,STOPPED</xsl:text>
</xsl:when>
<xsl:when test="evaluated='true'">
<xsl:text>,EVALUATED</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
I expected the result of:
stress_20150910_20150910_160259 EVALUATED
imm_20150910_20150910_140315 ACTIVE,EVALUATED
but what I got is:
OKstress_20150910_20150910_160259Mimm_20150910_20150910_030922falsetrueadmin2015-09-10T16:04:24.199-04:00rtcesupptruefalseimm_20150910_20150910_140315Mimm_20150910_20150910_030922truetrueadmin2015-09-10T14:04:42.696-04:00rtcesupptruefalse
It seemed like the XSL stylesheet was ignored. Could some one point me to correct XSL template matching syntax?
The fundamental problem in your XSL is that none of the XPath expression being used match the element in the source XML. Notice your XML has default namespace declared at the root element :
xmlns="http://www.algorithmics.com/schema"
Descendant elements without explicit prefix and without local default namespace inherits ancestor default namespace implicitly. To match element in namespace, simply declare a prefix that point to the namespace-uri and use that prefix in your XPath expressions, for example :
<xsl:stylesheet .....
xmlns:d="http://www.algorithmics.com/schema">
.....
<xsl:template match="/d:listDatasetsResponse/d:datasets/d:dataset">
<xsl:value-of select="d:id"/><xsl:text> </xsl:text>
.....
</xsl:template>
</xsl:stylesheet>
How about ...
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://www.algorithmics.com/schema"
version="1.0" >
<xsl:output method="text" encoding="utf-8"/>
<xsl:strip-space elements="*" />
<xsl:template match="#*|node()" />
<xsl:template match="/">
<xsl:apply-templates select="a:listDatasetsResponse/a:datasets/a:dataset" />
</xsl:template>
<xsl:template match="a:dataset">
<xsl:value-of select="a:id"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:active|a:stopped|a:evaluated" />
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="a:active[.='true']">
<xsl:if test="preceding-sibling::a:active[.='true']|
preceding-sibling::a:stopped[.='true']|
preceding-sibling::a:evaluated[.='true']">,</xsl:if>
<xsl:text>ACTIVE</xsl:text>
</xsl:template>
<xsl:template match="a:stopped[.='true']">
<xsl:if test="preceding-sibling::a:active[.='true']|
preceding-sibling::a:stopped[.='true']|
preceding-sibling::a:evaluated[.='true']">,</xsl:if>
<xsl:text>STOPPED</xsl:text>
</xsl:template>
<xsl:template match="a:evaluated[.='true']">
<xsl:if test="preceding-sibling::a:active[.='true']|
preceding-sibling::a:stopped[.='true']|
preceding-sibling::a:evaluated[.='true']">,</xsl:if>
<xsl:text>EVALUATED</xsl:text>
</xsl:template>
</xsl:stylesheet>
... or this version ...
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://www.algorithmics.com/schema"
version="1.0" >
<xsl:output method="text" encoding="utf-8"/>
<xsl:strip-space elements="*" />
<xsl:template match="#*|node()" />
<xsl:template match="/">
<xsl:apply-templates select="a:listDatasetsResponse/a:datasets/a:dataset" />
</xsl:template>
<xsl:template match="a:dataset">
<xsl:value-of select="a:id"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:active|a:stopped|a:evaluated" />
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="a:active[.='true'] | a:stopped[.='true'] | a:evaluated[.='true']">
<xsl:if test="preceding-sibling::a:active[.='true']|
preceding-sibling::a:stopped[.='true']|
preceding-sibling::a:evaluated[.='true']">,</xsl:if>
<xsl:value-of select="translate( local-name(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
</xsl:template>
</xsl:stylesheet>
Related
There are references I found in the internet about the passing of variable to other template. I tried to follow all the references but, I can't get the value that I need to populate. I have this xml file:
<Item>
<Test>
<ID>123345677</ID>
</Test>
<DisplayID>99884534</DisplayID>
</Item>
I need to populate MsgId element if the DisplayID is not null, else get value from the ID. My XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="ID">
<xsl:variable name="IDV" select="substring(.,0,35)"/>
<xsl:apply-templates select="DisplayID">
<xsl:with-param name="IDP" select="$IDV"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="DisplayID">
<xsl:param name="IDP"/>
<xsl:element name="MsgId">
<xsl:choose>
<xsl:when test=".!='' or ./*">
<xsl:value-of select="substring(.,0,35)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring($IDP,0,35)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
The condition if DisplayID is not null is working, however, if I remove the value of DisplayID, there's no value getting from the ID. I don't know if I doing it correctly.
Your feedback is highly appreciated.
Please try this,
Demo for references : http://xsltransform.net/ejivdHb/16
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://locomotive/bypass/docx" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Item">
<xsl:element name="MsgId">
<xsl:choose>
<xsl:when test="DisplayID !='' ">
<xsl:value-of select="substring(DisplayID , 0 ,35)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(Test/ID,0,35)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Since this is tagged XSLT 2.0, the match="Item" template from #TechBreak can be replaced by
<xsl:template match="Item">
<MsgId>
<xsl:value-of select="substring(
if (DisplayId != '')
then DisplayID
else Test/ID, 1 ,35)"/>
</MsgId>
</xsl:template>
(Note character counting starts from 1)
Consider following xml:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<base>
<a>
<b>
<c>Text 1</c>
</b>
</a>
</base>
<base>
<a>
<b>
<c>Text 2</c>
</b>
</a>
</base>
</root>
and this xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="root/base[1]" />
</xsl:template>
<xsl:template match="base//*">
<xsl:if test="text()">
<xsl:value-of select="text()" />
<!-- i need Text 2 here -->
</xsl:if>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
The original xml is much more nested an i don't know the exact structure. But there is a parallel node with the same structure. If my template is at //root/base[1]/a/b/c I want to reference //root/base[2]/a/b/c
However I only know that I am in some node below //root/base[1] and that there is the same node in //root/base[2].
Is there a possibility to accomplish this goal?
This stylesheet requires no extensions, and does not make any assumption on unique names; the boring part is to pass the correct "twin node" every time you call xsl:apply-templates:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="root/base[1]">
<xsl:with-param name="twin" select="root/base[2]"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*">
<xsl:param name="twin"/>
<xsl:if test="text()">
<xsl:value-of select="text()" />
<xsl:value-of select="$twin/text()"/>
</xsl:if>
<xsl:for-each select="*">
<xsl:variable name="pos" select="position()"/>
<xsl:apply-templates select=".">
<xsl:with-param name="twin" select="$twin/*[$pos]"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
Solution with using saxon:evaluate extension (http://saxon.sourceforge.net/saxon7.9/extensions.html#evaluate)
You can also use dyn:evaluate if you are using xslt 1.0 processors (http://exslt.org/dyn/index.html):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xmlns:saxon="http://saxon.sf.net/"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="root/base[1]" />
</xsl:template>
<xsl:template match="base//*">
<xsl:if test="text()">
<xsl:variable name="path">
<xsl:call-template name="constructPath">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="rewritedPath" select="concat('/root/base[2]', substring($path, 11))"/>
<xsl:value-of select="text()" />
<xsl:value-of select="saxon:evaluate($rewritedPath)" />
</xsl:if>
<xsl:apply-templates />
</xsl:template>
<xsl:template name="constructPath">
<xsl:param name="node"/>
<xsl:choose>
<xsl:when test="$node/parent::node()/name()">
<xsl:call-template name="constructPath">
<xsl:with-param name="node" select="$node/parent::node()"/>
</xsl:call-template>
<xsl:value-of select="concat('/', $node/name())"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('/', $node/name())"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
Here we use recursive template "constructPath" to create string and process it in evaluate() function. This will select the exact node as in the parallel branch. Hope this will help.
Try the code below. This code will work only if each base element has children with unique element name.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="root/base[1]" />
</xsl:template>
<xsl:template match="base//*">
<xsl:if test="text()">
<xsl:variable name="name" select="name()"/>
<xsl:value-of select="text()" />
<xsl:value-of select="ancestor::base/following-sibling::base[1]//*[name() = $name]" />
</xsl:if>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="text()" />
However you can use dyn:evaluate from exslt extension or saxon:eval
Trying to reference namespace to the same xslt with document('') but I get :
SystemID: file:/c:/intersystems/cache/mgr/samples/; Line#: 1; Column#: 1
net.sf.saxon.trans.XPathException: Error reported by XML parser
....
Caused by: org.xml.sax.SAXParseException; systemId: file:/c:/intersystems/cache/mgr/samples/; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
So it seems can not reference the same xslt? Is there some way to do this
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:csv="csv:csv">
<!-- <xsl:output method="text" version="4.0" encoding="iso-8859-1" indent="yes"/> -->
<xsl:strip-space elements="*" />
<xsl:output method="text" encoding="utf-8" />
<xsl:variable name="delimiter" select="','"/>
<csv:columns>
<column>GlobalID</column>
<column>ServicePointName</column>
</csv:columns>
<xsl:template match="/Report">
<!-- Output the CSV header -->
****<xsl:for-each select="document('')/*/csv:columns/*">****
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:value-of select="$delimiter"/>
</xsl:if>
</xsl:for-each>
<xsl:text>
</xsl:text>
<!-- Output rows for each matched Report -->
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="/Report/CLI">
<xsl:for-each select="//CLI">
<xsl:value-of select="GlobalID"/>
<xsl:value-of select="$delimiter"/>
<xsl:value-of select="ServicePointName"/>
<!-- Add a newline at the end of the record -->
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Saxon 9 is an XSLT 2.0 processor - so you can easily do:
XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="delimiter" select="','"/>
<xsl:variable name="columns">
<column>GlobalID</column>
<column>ServicePointName</column>
</xsl:variable>
<xsl:template match="/">
<xsl:for-each select="$columns/*">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:value-of select="$delimiter"/>
</xsl:if>
</xsl:for-each>
<xsl:text>
</xsl:text>
<!-- the rest -->
</xsl:template>
</xsl:stylesheet>
I don't see that you're using the columns further on in your stylesheet. If so, why don't you simplify the whole thing to:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:text>GlobalID,ServicePointName
</xsl:text>
<!-- the rest -->
</xsl:template>
</xsl:stylesheet>
(which is also XSLT 1.0 compatible).
None of this explains why your attempt to use an internal node wouldn't work.
I've never tried to do this, but just looking at the documentation for the document() function it says this:
document() Used to access the nodes in an external XML document
Edit: I jumped the gun as pointed out by comments below. There is another question facing the same problems:
XSLT document('') function doesn't work
I'm trying to convert an XML file into a flat, pipe-delimited file with XSLT (for bulk-loading into Postgres). I would like the last column in my output to be the actual XML of the node (for additional post-processing and debugging). For example:
<Library>
<Book id="123">
<Title>Python Does Everythig</Title>
<Author>Smith</Author>
</Book>
<Book id="456">
<Title>Postgres is Neat</Title>
<Author>Wesson</Author>
</Book>
</Library>
Should generate
Python Does Everything|Smith|<Book id="123"><Title>Python Does Everythig</Title>Author>Smith</Author></Book>
Postgres is Neat|Wesson|<Book id="456"><Title>Postgres is Neat</Title><Author>Wesson</Author></Book>
My current XSL is
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*" />
<xsl:output method="text" omit-xml-declaration="yes" indent="no" />
<xsl:template match="//Book">
<xsl:value-of select="Title" />
<xsl:text>|</xsl:text>
<xsl:value-of select="Author" />
<!-- put in the newline -->
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
I am not sure if this is a recommended solution, but you could try setting the output method to xml, and then just using the xsl:copy-of function.
So, the following XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*" />
<xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
<xsl:template match="//Book">
<xsl:value-of select="Title" />
<xsl:text>|</xsl:text>
<xsl:value-of select="Author" />
<xsl:text>|</xsl:text>
<xsl:copy-of select="." />
<!-- put in the newline -->
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
When applied to your sample XML, generates the following output
Python Does Everythig|Smith|<Book id="123"><Title>Python Does Everythig</Title><Author>Smith</Author></Book>
Postgres is Neat|Wesson|<Book id="456"><Title>Postgres is Neat</Title><Author>Wesson</Author></Book>
Try that :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="//Book"/>
</xsl:template>
<xsl:template match="Book">
<xsl:value-of select="Title" />
<xsl:text>|</xsl:text>
<xsl:value-of select="Author" />
<xsl:text>|</xsl:text>
<xsl:apply-templates select="." mode="outputTags"/>
</xsl:template>
<xsl:template match="*" mode="outputTags">
<xsl:text><</xsl:text>
<xsl:value-of select="local-name()"/>
<xsl:apply-templates select="#*"/>
<xsl:text>></xsl:text>
<xsl:apply-templates mode="outputTags"/>
<xsl:text></</xsl:text>
<xsl:value-of select="local-name()"/>
<xsl:text>></xsl:text>
<xsl:if test="self::Book">
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="#*">
<xsl:text> </xsl:text>
<xsl:value-of select="local-name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"</xsl:text>
</xsl:template>
</xsl:stylesheet>
It produces the following result from your input file :
Python Does Everythig|Smith|<Book id="123"><Title>Python Does Everythig</Title><Author>Smith</Author></Book>
Postgres is Neat|Wesson|<Book id="456"><Title>Postgres is Neat</Title><Author>Wesson</Author></Book>
My xsl file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:go="http://www.google.com"
exclude-result-prefixes="go">
<xsl:include href="SomeLibrary.xsl"/>
<xsl:template match="/">
<xsl:call-template name="SomeTemplate">
<xsl:with-param name="Element" select="'randomParam'"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
The SomeLibrary.xsl file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.google.com">
<xsl:template name="SomeTemplate">
<xsl:param name="Element"/>
<Blabla>
<xsl:value-of select="$Element" />
</Blabla>
</xsl:template>
</xsl:stylesheet>
Input xml: just use an empty XML. The result is this:
<?xml version="1.0" encoding="UTF-8"?>
<Blabla xmlns="http://www.google.com">
randomParam
</Blabla>
What I want is to have the "Blabla" node without a namespace. How can I remove it or make sure it doesn't get there, without modifying my "SomeLibrary.xsl"?
In case you don't want to edit the imported stylesheet code, the way to remove the namespace is with a two-pass transformation (which in XSLT 1.0 requires using an xxx:node-set() extension function):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="vrtfPass1">
<xsl:call-template name="SomeTemplate">
<xsl:with-param name="Element" select="'randomParam'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="vPass1" select="ext:node-set($vrtfPass1)"/>
<xsl:apply-templates select="$vrtfPass1/node()" mode="pass2"/>
</xsl:template>
<xsl:template match="*" mode="pass2">
<xsl:element name="{name()}">
<xsl:copy-of select="#*"/>
<xsl:apply-templates mode="pass2"/>
</xsl:element>
</xsl:template>
<xsl:template name="SomeTemplate" xmlns="http://www.google.com">
<xsl:param name="Element"/>
<Blabla>
<xsl:value-of select="$Element" />
</Blabla>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on any XML document (not used), the wanted result (the default namespace removed) is produced:
<Blabla>randomParam</Blabla>
Update:
The OP has indicated in a comment that he is using Xalan 2.07.
Below is almost the same solution, but with namespace and name for the xxx:node-set() function, as used in Xalan:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="x" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="vrtfPass1">
<xsl:call-template name="SomeTemplate">
<xsl:with-param name="Element" select="'randomParam'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="vPass1" select="x:nodeset($vrtfPass1)"/>
<xsl:apply-templates select="$vrtfPass1/node()" mode="pass2"/>
</xsl:template>
<xsl:template match="*" mode="pass2">
<xsl:element name="{name()}">
<xsl:copy-of select="#*"/>
<xsl:apply-templates mode="pass2"/>
</xsl:element>
</xsl:template>
<xsl:template name="SomeTemplate" xmlns="http://www.google.com">
<xsl:param name="Element"/>
<Blabla>
<xsl:value-of select="$Element" />
</Blabla>
</xsl:template>
</xsl:stylesheet>
Explicitly create them with:
<xsl:element name="Blabla" namespace="">...</xsl:element>
but this means fiddling with the SomeLibrary.xsl file.
add exclude-result-prefixes="go" to the stylesheet element.
and, of course, update the namespace declaration from the default one to xmlns:go="http://www.google.com"