xtremebytes2002
asked on
Adding attributes on-the-fly through XSL
After generating an XML through an XSL transformation on another XSL, if I want to add (on-the-fly) the namespace and schema location attributes to the root element of the generated XML file, then how do I go about it? I used <xsl:attribute> as follows.
<xsl:attribute name="xmlns:xsi">http://www.w3.org/2001/XMLSchema-instance</xsl:att ribute>
<xsl:attribute name="xsi:noNamespaceSchem aLocation" >myschema. xsd</xsl:a ttribute>
This generates warning/error on the XML transformation engine (using javax.xml.transform.*) saying that I have used illegal attribute names. How to insert those attributes then?
Thanks a lot in advance.
<xsl:attribute name="xmlns:xsi">http://www.w3.org/2001/XMLSchema-instance</xsl:att
<xsl:attribute name="xsi:noNamespaceSchem
This generates warning/error on the XML transformation engine (using javax.xml.transform.*) saying that I have used illegal attribute names. How to insert those attributes then?
Thanks a lot in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks a lot spark plug
The following is an example of how this would be done:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:template match="/">
<root>
<xsl:attribute name="xsi:noNamespaceSchem
</root>
</xsl:template>
</xsl:stylesheet>
Hope this helps.
>S'Plug<