Trouble with placing xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" correct in the output xml file.

Questions about XML that are not covered by the other forums should go here.
carlzone
Posts: 1
Joined: Mon Jan 06, 2025 11:07 am

Trouble with placing xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" correct in the output xml file.

Post by carlzone »

I'm trying to place xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" statement here:

Code: Select all

<EG401.TRANSACTION [b]xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" [/b]xs:noNamespaceSchemaLocation="/aspect4/businessconnector/schemas/EGLDT/EG405.ACCOUNT.ACC.xsd" type="ABCSchema" time="120101" stock="0" runtype="*PROD" languages="95 97 07 91 00" id="DOCUMENT" group="7" docuniqueid="Q2024122040" date="20241220" company="735" >
But it is placed at the end like this:

Code: Select all

<EG401.TRANSACTION xs:noNamespaceSchemaLocation="/aspect4/businessconnector/schemas/EGLDT/EG405.ACCOUNT.ACC.xsd" type="ABCSchema" time="120101" stock="0" runtype="*PROD" languages="95 97 07 91 00" id="DOCUMENT" group="7" docuniqueid="Q2024122040" date="20241220" company="735" [b]xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"[/b]>
This is some of my xslt file:

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">

 <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" omit-xml-declaration="no" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"/>

      <!-- 
2024.10.08 Lars Carlsson - Initial version
General rule for templates: select on xml-names from tpl_fields.xml.
-->

	<xsl:variable name="belop-11v2">#0.00</xsl:variable>
	<xsl:decimal-format name="belop" decimal-separator="."/>

      
     <xsl:template match="/">
<xsl:text>&#13;&#10;</xsl:text>
<EG401.TRANSACTION>
	<xsl:attribute  name="xs:noNamespaceSchemaLocation">/aspect4/businessconnector/schemas/EGLDT/EG405.ACCOUNT.ACC.xsd</xsl:attribute>
	<xsl:attribute name="type">ABCSchema</xsl:attribute>
	<xsl:attribute name="time">120101</xsl:attribute>
	<xsl:attribute name="stock">0</xsl:attribute>
	<xsl:attribute name="runtype">*PROD</xsl:attribute>
	<xsl:attribute name="languages">95 97 07 91 00</xsl:attribute>
	<xsl:attribute name="id">DOCUMENT</xsl:attribute>
	<xsl:attribute name="group">7</xsl:attribute>
	<xsl:attribute name="docuniqueid">Q<xsl:value-of select="//transaction/bilagsdato"/><xsl:value-of select="//transaction/runnr"/></xsl:attribute>
	<xsl:attribute name="date"><xsl:value-of select="//transaction/bilagsdato"/></xsl:attribute>
	<xsl:attribute name="company"><xsl:value-of select="//transaction/firmaid"/></xsl:attribute>
<xsl:text>&#13;&#10;</xsl:text>
Does anyone know how to get the output correct?
Martin Honnen
Posts: 102
Joined: Tue Aug 19, 2014 12:04 pm

Re: Trouble with placing xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" correct in the output xml file.

Post by Martin Honnen »

Attributes order does not matter so why do you think you need or want that particular attribute as the first one?

I don't think XSLT ensures/allows a certain attribute serialization order.
Post Reply