XSLT 1.0 - Change/add namespace to nodes - xslt

I am currently trying to create an XSLT 1.0 mapping in SAP PI to change/add namespace of specific nodes. Given the Input.xml I have to create a XSL-file to get the Output.xml as you can see below. Unfortunately all my attempts were not successful so far. I would be happy if anybody can provide an XSL sheet to solve this issue. I would be glad if someone could help me, as I am already very close to despair.
Input.XML
<?xml version="1.0" encoding="UTF-8"?>
<ns0:serviceABC xmlns:ns0="http://namespaceToReplace">
<XYZ>
<Zugang>
<MandantCode>test</MandantCode>
<BenutzerId>test</BenutzerId>
<Password>test</Password>
</Zugang>
<Personen>
<GpCode>0000000001</GpCode>
<Name>Name1</Name>
<LandCode>DE</LandCode>
</Personen>
<Personen>
<GpCode>0000000002</GpCode>
<Name>Name2</Name>
<LandCode>DE</LandCode>
</Personen>
<Personen>
<GpCode>0000000003</GpCode>
<Name>Name3</Name>
<LandCode>DE</LandCode>
</Personen>
<Personen>
<GpCode>0000000004</GpCode>
<Name>Name4</Name>
<LandCode>DE</LandCode>
</Personen>
</XYZ>
</ns0:serviceABC>
Output.XML ("ns0:" - prefix needs to be removed, "xmlns="http://newNamespace1"" has to be replaced in node serviceABC, "xmlns="http://newNamespace2"" has to be added to node XYZ):
<?xml version="1.0" encoding="UTF-8"?>
<serviceABC xmlns="http://newNamespace1">
<XYZ xmlns="http://newNamespace2">
<Zugang>
<MandantCode>test</MandantCode>
<BenutzerId>test</BenutzerId>
<Password>test</Password>
</Zugang>
<Personen>
<GpCode>0000000001</GpCode>
<Name>Name1</Name>
<LandCode>DE</LandCode>
</Personen>
<Personen>
<GpCode>0000000002</GpCode>
<Name>Name2</Name>
<LandCode>DE</LandCode>
</Personen>
<Personen>
<GpCode>0000000003</GpCode>
<Name>Name3</Name>
<LandCode>DE</LandCode>
</Personen>
<Personen>
<GpCode>0000000004</GpCode>
<Name>Name4</Name>
<LandCode>DE</LandCode>
</Personen>
</XYZ>
</serviceABC>
I am looking forward hearing from you guys.
Source code developed that did not work at all

"xmlns="http://newNamespace2"" has to be added to node XYZ):
I don't think you understand the nature of your task. This is not a matter of adding a namespace declaration to a single node.
In your output, the XYZ element and all its descendants have been moved into the new namespace. That means they all have to be renamed (as does the root ns0:serviceABC element):
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://namespaceToReplace"
exclude-result-prefixes="ns0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/ns0:serviceABC">
<serviceABC xmlns="http://newNamespace1">
<xsl:apply-templates/>
</serviceABC>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="http://newNamespace2">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Related

Adding missing nodes to XML via XSLT

I'm using a tool to import XML files into Dynamics NAV, but some parties providing the XML files skip empty nodes. My tool (external) can not handle those situation so I want to include XSLT to add the missing nodes. The xslt works fine for 1 node, but adding multiple nodes does not work. So I must be doing something wrong.
I'm building an integration to Dynamics NAV to insert Sales Orders. The orders are delivered from multiple parties using a XML file. However some of the parties providing the XML do not list all nodes in their XML file, they skip the empty ones. I'm using a tool build within Dynamics NAV (Add-on from other vendor) to import those files. However some XML files go wrong because of the fact that some (empty) nodes are missing in the XML file. I know this is an issue within the add-on but I need a solution on short notice. So created an XSLT to add the missing nodes. It works fine with 1 missing node, but it is not able to add both missing nodes. I'm not that familiar with XSLT so most of the times it is trial & error. Perhaps someone can help me with this.
This is the XML file format that is provided, The nodes that are sometimes missing is the DeliveryParty node and the DeliveryAddress part.
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<Orders>
<Order>
<Partner>
<SenderEANCode>9999999999999</SenderEANCode>
<RecipientEANCode>9999999999999</RecipientEANCode>
</Partner>
<OrderHeader>
<OrderVersion>008</OrderVersion>
<OrderTypeCode>220</OrderTypeCode>
<Document>
<DocumentNumber>34034040</DocumentNumber>
<Date>2019-04-18</Date>
</Document>
<DeliveryDate>2019-04-24</DeliveryDate>
<CompleteDelivery>YES</CompleteDelivery>
<Supplier>9999999999999</Supplier>
<Buyer>9999999999999</Buyer>
<Invoicee>9999999999999</Invoicee>
<DeliveryParty>9999999999999</DeliveryParty>
<DeliveryAddress>
<DeliveryName>Private Customer</DeliveryName>
<DeliveryStreet>Teststraat</DeliveryStreet>
<DeliveryCity>TestCity</DeliveryCity>
<DeliveryCountry>NL</DeliveryCountry>
<DeliveryTelNo></DeliveryTelNo>
<DeliveryEmail>test#test.com</DeliveryEmail>
</DeliveryAddress>
</OrderHeader>
<OrderLine>
<LineItemNumber>1</LineItemNumber>
<GTIN>9999999999999</GTIN>
<OrderedQuantity>
<Quantity>260</Quantity>
</OrderedQuantity>
</OrderLine>
</Order>
</Orders>
Sometimes the DeliveryParty node is missing and other times the DeliveryAddress part including subnodes is missing. I created the following XSLT to add those nodes but as it is trail and error I need some help to fix this. I'm a novice to XSLT, I can so some small changes but I do not use it frequently so knowledge is fading away quickly.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Orders/Order/OrderHeader[not(DeliveryParty)]">
<xsl:copy-of select="*"/>
<DeliveryParty/>
</xsl:template>
<xsl:template match="Orders/Order/OrderHeader[not(//DeliveryAddress)]">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
<DeliveryAddress>
<DeliveryName></DeliveryName>
<DeliveryStreet></DeliveryStreet>
<DeliveryPostalCode></DeliveryPostalCode>
<DeliveryCity></DeliveryCity>
<DeliveryCountry></DeliveryCountry>
<DeliveryTelNo></DeliveryTelNo>
<DeliveryEmail></DeliveryEmail>
</DeliveryAddress>
</xsl:copy>
</xsl:template>
With above mentioned XSLT the DeliveryAddress node with it's subnodes is added but the deliveryparty is not.
When the file is delivered like this:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<Orders>
<Order>
<Partner>
<SenderEANCode>9999999999999</SenderEANCode>
<RecipientEANCode>9999999999999</RecipientEANCode>
</Partner>
<OrderHeader>
<OrderVersion>008</OrderVersion>
<OrderTypeCode>220</OrderTypeCode>
<Document>
<DocumentNumber>34034040</DocumentNumber>
<Date>2019-04-18</Date>
</Document>
<DeliveryDate>2019-04-24</DeliveryDate>
<CompleteDelivery>YES</CompleteDelivery>
<Supplier>9999999999999</Supplier>
<Buyer>9999999999999</Buyer>
<Invoicee>9999999999999</Invoicee>
</OrderHeader>
<OrderLine>
<LineItemNumber>1</LineItemNumber>
<GTIN>9999999999999</GTIN>
<OrderedQuantity>
<Quantity>260</Quantity>
</OrderedQuantity>
</OrderLine>
</Order>
</Orders>
The outcome should be this:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<Orders>
<Order>
<Partner>
<SenderEANCode>9999999999999</SenderEANCode>
<RecipientEANCode>9999999999999</RecipientEANCode>
</Partner>
<OrderHeader>
<OrderVersion>008</OrderVersion>
<OrderTypeCode>220</OrderTypeCode>
<Document>
<DocumentNumber>34034040</DocumentNumber>
<Date>2019-04-18</Date>
</Document>
<DeliveryDate>2019-04-24</DeliveryDate>
<CompleteDelivery>YES</CompleteDelivery>
<Supplier>9999999999999</Supplier>
<Buyer>9999999999999</Buyer>
<Invoicee>9999999999999</Invoicee>
<DeliveryParty></DeliveryParty>
<DeliveryAddress>
<DeliveryName></DeliveryName>
<DeliveryStreet></DeliveryStreet>
<DeliveryCity></DeliveryCity>
<DeliveryCountry></DeliveryCountry>
<DeliveryTelNo></DeliveryTelNo>
<DeliveryEmail></DeliveryEmail>
</DeliveryAddress>
</OrderHeader>
<OrderLine>
<LineItemNumber>1</LineItemNumber>
<GTIN>9999999999999</GTIN>
<OrderedQuantity>
<Quantity>260</Quantity>
</OrderedQuantity>
</OrderLine>
</Order>
</Orders>
How about:
XSLT 1.0
<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:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="OrderHeader">
<xsl:copy>
<xsl:apply-templates/>
<xsl:if test="not(DeliveryParty)">
<DeliveryParty/>
</xsl:if>
<xsl:if test="not(DeliveryAddress)">
<DeliveryAddress>
<DeliveryName/>
<DeliveryStreet/>
<DeliveryPostalCode/>
<DeliveryCity/>
<DeliveryCountry/>
<DeliveryTelNo/>
<DeliveryEmail/>
</DeliveryAddress>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

How to add namespace and xsi to the Incoming XML with no namespace

I have requirement where I have to add Namespace and xsi to the
element from the source xml with No Namespace.
In Source XML I am just getting the Nodes and there is No namespace
and another program needs BizTalk to add Namespace and XSI to the XML for its processing.
I tried:
Used add namespace pipeline component. (It just added
namespace and not the xsi bits)
Used Map for putting up the desired format and yes no luck as got
just the namespace.
Need your help around this.
My source XML is like
<?xml version="1.0" encoding="UTF-16"?>
<Document>
<CstmrPmtStsRpt>
<GrpHdr>
<MsgId></MsgId>
<CreDtTm></CreDtTm>
<InitgPty>
<Id>
<OrgId>
<BICOrBEI></BICOrBEI>
</OrgId>
</Id>
</InitgPty>
</GrpHdr>
<OrgnlGrpInfAndSts>
<OrgnlMsgId></OrgnlMsgId>
<OrgnlMsgNmId></OrgnlMsgNmId>
<OrgnlNbOfTxs></OrgnlNbOfTxs>
<OrgnlCtrlSum></OrgnlCtrlSum>
<GrpSts>ACCP</GrpSts>
</OrgnlGrpInfAndSts>
</CstmrPmtStsRpt>
</Document>
My Required format is as below:
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="MyNamespace">
<CstmrPmtStsRpt>
<GrpHdr>
<MsgId></MsgId>
<CreDtTm></CreDtTm>
<InitgPty>
<Id>
<OrgId>
<BICOrBEI></BICOrBEI>
</OrgId>
</Id>
</InitgPty>
</GrpHdr>
<OrgnlGrpInfAndSts>
<OrgnlMsgId></OrgnlMsgId>
<OrgnlMsgNmId></OrgnlMsgNmId>
<OrgnlNbOfTxs></OrgnlNbOfTxs>
<OrgnlCtrlSum></OrgnlCtrlSum>
<GrpSts>ACCP</GrpSts>
</OrgnlGrpInfAndSts>
</CstmrPmtStsRpt>
</Document>
Use the namespace attribute of xsl:element like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="MyNamespace">
<xsl:namespace name="xsi" select="'http://www.w3.org/2001/XMLSchema-instance'"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Edit: Since you need to work with XSLT-1.0. Use following stylesheet:
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/Document">
<Document xmlns="MyNamespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:apply-templates/>
</Document>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="MyNamespace">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Note, that you need to know your rootnode's name for this (in this case Document).
BizTalk Answer:
First, it's a good thing the incoming document has no namespace. Xml Namespaces are far, far, far more trouble than they're worth and should be avoided/removed whenever possible.
Second the output format is not valid Xml. "MyNamespace" is not a valid URI and can't be used for a Namespace. If this is what they are asking for, they need to fix that first.
But, if you must, your process should not be "add a namespace". What you're really doing is Transforming from SysA's Document to SysB's Document. For that, use a Map. You will use to practially identical Schemas, one with and one without the Target Namespace.
The Mapper will handle xsi for you as well, if it's needed.

BizTalk - adding namespace to xml

I'm new to BizTalk and I'm having problems with adding a namespace to my output file.
I need to get the following output, with the namespace at the root level:
<?xml version="1.0" encoding="utf-8"?>
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing/>
<POHeader/>
</TestExternalPO>
My xsd is:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
elementFormDefault="qualified" version="1.0">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo BizTalkServerEditorTool_Version="1.5" root_reference="TestExternalPO"
displayroot_reference="TestExternalPO" standard="XML"
targetNamespace="http://Test.EDI.TestExternalPO.Schemas"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
My xslt is:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="TestExternalPO"/>
</xsl:template>
<xsl:template match="TestExternalPO">
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing>....
Any help greatly appreciated,
Maggs
Update 25-Apr.
Thanks for all the comments.
The above setup works but doesn't give me what I want i.e namespace at root level.
I did test the namespace in the xslt but got an error on BizTalk.
<xsl:template match="TestExternalPO">
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing>
<xsl:attribute name="SendPartner">
BizTalk Error - Finding the document specification by message type "http://Test.EDI.TestExternalPO.Schemas" failed. Verify the schema deployed properly.
Below is structure of input file:
<TestExternalPO>
<POHeader>
</POHeader>
<TradingPartnersList>
<TradingPartners>
</TradingPartners>
</TradingPartnersList>
<Contract>
</Contract>
<ItemsList>
<Items>
</Items>
</ItemsList>
</TestExternalPO>
The problem is with my declaration of 'xmlns'.
If I add 'targetNamespace', then output has the targetNamespace at the root element.
This works:
<xsl:template match="TestExternalPO">
<TestExternalPO targetNamespace="http://Test.EDI.TestExternalPO.Schemas">
<Routing>
<xsl:attribute name="SendPartner">
Again thanks for the help.
Maggs
Here's how your xslt should look. You want to exclude namespace so add the prefix to exclude-result-prefixes
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="ns0"
xmlns:ns0="http://Test.EDI.TestExternalPO.Schemas">
<xsl:template match="/">
<xsl:apply-templates select="TestExternalPO"/>
</xsl:template>
<xsl:template match="TestExternalPO">
<ns0:TestExternalPO>
<Routing>....

Copy comments that are after the end of root tag using XSLT

I have an XML which needs to be reordered and stored in another file. I have done an xslt for that and it works fine.
However if there are comments after the xml ends then these comments are not copied. I need an xslt statement that copies comments which are present
after the root tag ends
Below is a code that explains the following
Original XML
<Company>
<Employee id="100" Name="John" >
<Salary value="15000"/>
<Qualification text="Engineering">
<State name="Kerala" code="02">
<Background text="Indian">
</Employee>
</Company>
<!--This file contains Employee information-->
<!--Please refer the file to get information about an employee-->
XSLT Transformation code
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output indent="yes" omit-xml-declaration="yes" method="xml" />
<xsl:strip-space elements="*"/>
<xsl:template match="#* | node()">
<xsl:copy>
<xsl:apply-templates select="#* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Employee">
<xsl:copy>
<xsl:apply-templates select="Qualification"/>
<xsl:apply-templates select="Salary" />
<xsl:apply-templates select="Background"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Output Obtained
<?xml version="1.0" encoding="utf-8"?>
<Company>
<Employee>
<Qualification text="Engineering" />
<Salary value="15000" />
<Background text="Indian" />
</Employee>
</Company>
Output Required
<?xml version="1.0" encoding="utf-8"?>
<Company>
<Employee>
<Qualification text="Engineering" />
<Salary value="15000" />
<Background text="Indian" />
</Employee>
</Company>
<!--This file contains Employee information-->
<!--Please refer the file to get information about an employee-->
There's nothing wrong with your transformation. I ran the same XSLT over the same XML (corrected to make it well-formed) using xsltproc and I get the correct output including the trailing comments (though they have lost their original indentation and spacing due to the strip-space and the indent="yes" in the stylesheet)
<Company>
<Employee>
<Qualification text="Engineering"/>
<Salary value="15000"/>
<Background text="Indian"/>
</Employee>
</Company><!--This file contains Employee information-->
<!--Please refer the file to get information about an employee-->
It looks like whatever processor or XML parser you're using (presumably a Microsoft one judging by the xmlns:msxsl="urn:schemas-microsoft-com:xslt") is ignoring comments after the end tag of the document element.

xpath-function max doesn't work

For unknown reason max function doesn't work.
XML input file:
test.xml
<?xml version="1.0" encoding="UTF-8"?>
<numbers>
<number>3</number>
<number>5</number>
<number>10</number>
<number>1</number>
</numbers>
XSL input file
test.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" >
<xsl:output method="xml" indent="yes" />
<xsl:template match="/numbers">
<numbers>
<xsl:value-of select="/numbers/number" />
fn:max(2, 3)
</numbers>
</xsl:template>
</xsl:stylesheet>
Output.xml
<?xml version="1.0" encoding="UTF-8"?>
<numbers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">3
fn:max(2, 3)
</numbers>
Input file is not important here, but I would like to have '3' instead of fn:max(2, 3). How to do it?
for this XSL file:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" >
<xsl:output method="xml" indent="yes" />
<xsl:template match="/numbers">
<numbers>
<xsl:value-of select="/numbers/number" />
fn:max(2, 3)
<xsl:value-of select="max(/numbers/number)"/>
</numbers>
</xsl:template>
</xsl:stylesheet>
the following error occurs:
SystemId Unknown; Line #13; Column #49; Could not find function: max
SystemId Unknown; Line #13; Column #49; function token not found.
(Location of error unknown)java.lang.NullPointerException
(Location of error unknown)XSLT Error (javax.xml.transform.TransformerException)
: No xml-stylesheet PI found in: test.xml
Exception in thread "main" java.lang.RuntimeException: No xml-stylesheet PI foun
d in: test.xml
at org.apache.xalan.xslt.Process.doExit(Process.java:1155)
at org.apache.xalan.xslt.Process.main(Process.java:1128)
I used Xalan - Version Xalan Java 2.7.1, Command: java org.apache.xalan.xslt.Process -in test.xml -xsl test.xsl -out output.xml
There are several problems: max() needs to be in a value-of, and that you've said xsl:stylesheet version="2.0" for Xalan, which only supports XSLT 1.0. For 2.0, you'd need Saxon 9.x.
Since max() isn't part of XSLT 1.0, you need to invoke the EXSLT extension support, which Xalan does have:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math">
<xsl:template match="/numbers">
<xsl:value-of select="math:max(number)"/>
</xsl:template>
</xsl:stylesheet>
or
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math">
<xsl:template match="/">
<xsl:value-of select="math:max(numbers/number)"/>
</xsl:template>
</xsl:stylesheet>
You've put fn:max(2,3) in a text block. Nothing is going to interpret that. You need to put functions in value-of expressions if you want them to be evaluated.
Lavino,
Thanks for the response. I don't know why but I was pretty sure that Xalan supports 2.0... I've tested it and it works for Saxon 9.
You can use
<xsl:value-of select="max(number)" />
to get the max of all numbers.
Soln:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/numbers">
<numbers>
<max>
<xsl:value-of select="max(number)"/>
</max>
<xsl:apply-templates/>
</numbers>
</xsl:template>
<xsl:template match="number">
<number>
<xsl:value-of select="."/>
</number>
</xsl:template>
</xsl:stylesheet>
You can omit the number template and <xsl:apply-templates/> if its not reqd. This will be the output with the above xslt:
<?xml version="1.0" encoding="UTF-8"?>
<numbers xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<max>10</max>
<number>3</number>
<number>5</number>
<number>10</number>
<number>1</number>
</numbers>