How to add more namespaces to one element by XSLT
Posted: Sat Feb 02, 2019 8:11 pm
Hi,
I am sorry but I am desparate. I am new to XSLT developing and I thought that it will be easy but the creating of XSLT that will do exactly what I want is not so easy.
I need to add more namespaces to one element by XSLT.
See. I need to create this XML file:
There is used the namespace prefix "inv" for invoice "inv:invoice" and then for invoiceHeader there are used two prefixes like "typ" and "rsp". Of cousre I can create it in text editor and it works but i need to create it automaticaly by XSLT template so I can automate the invoices that I have in XML file from our supplier.
I have created this XSLT file:
But it does not generate the result I need. Please can somebody help say how to add more namespaces with prefixes to one element y XSLT?
Best Reagrds
I am sorry but I am desparate. I am new to XSLT developing and I thought that it will be easy but the creating of XSLT that will do exactly what I want is not so easy.
I need to add more namespaces to one element by XSLT.
See. I need to create this XML file:
Code: Select all
<?xml version="1.0" encoding="Windows-1250"?>
<inv:invoice version="2.0" xmlns:inv="http://www.stormware.cz/schema/version_2/invoice.xsd">
<inv:invoiceHeader xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd" xmlns:rsp="http://www.stormware.cz/schema/version_2/response.xsd" >
</inv:invoiceHeader>
</inv:invoice>
I have created this XSLT file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:attribute-set name="ver">
<xsl:attribute name="version">2.0</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/">
<xsl:element name="inv:invoice" namespace="http://www.stormware.cz/schema/version_2/invoice.xsd" use-attribute-sets="ver">
<xsl:element name="inv:invoiceHeader" namespace="http://www.stormware.cz/schema/version_2/invoice.xsd" xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd" xmlns:rsp="http://www.stormware.cz/schema/version_2/response.xsd">
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Best Reagrds