This XSL transform applied on the source XML you provided will generate the expected result:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="dataroot">
<xml><xsl:apply-templates/></xml>
</xsl:template>
<xsl:template match="Mnc_x0020_172">
<package id="{package_id}" cat="{cat}">
<nazwa><xsl:value-of select="nazwa"/></nazwa>
<author><xsl:value-of select="author"/></author>
<www><xsl:value-of select="translate(www,'#','')"/></www>
<opis><xsl:value-of select="opis"/></opis>
<img><xsl:value-of select="translate(img,'#','')"/></img>
</package>
</xsl:template>
</xsl:stylesheet>
The match
attribute in each xsl:template
matches a node in your source document using XPath. The first template matches the dataroot
node, adds a <xml>...</xml>
root node to the output and calls for the processing of the other templates. The second template will match a nodeset formed by your two Mnc-x0020_172
nodes, will generate a <package>
element for each one and will select the nodes from your source (in context) and place them in an element of the same name. translate
is used to remove the #
.
There are other ways to obtain the same results. If you didn't have a namespace declaration, you could have used <xsl:copy-of select="node">
to copy the nodes that are identical on both documents.