xsl-list
[Top] [All Lists]

Re: [xsl] schema reference in output

2009-04-20 05:17:56


Namespace declarations are not attributes in Xpath.

In this case the simplest change to your code is to remove

        <xsl:attribute name="xmlns:xsi"><xsl:value-of select
="'http://www.w3.org/2001/XMLSchema-instance'"/>

which is causing the error.

Add xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"; to your
styleshet then when the processor sees

        <xsl:attribute name="xmlns:xsi"

It will know which namespace is meant by xsi: and a namespace node will
be added automatically.


actually I wouldn't use xsl:attribute at all

        <xsl:element name="Employees">

                        <!-- schema verwijzingsattributen in main -->
                        <!-- THIS IS WHERE IM HAVING TROUBLE -->
                        <xsl:attribute name="xmlns:xsi"><xsl:value-of select
="'http://www.w3.org/2001/XMLSchema-instance'"/></xsl:attribute>
                        <xsl:attribute 
name="xsi:noNamespaceSchemaLocation"><xsl:value-of
select ="'400_o_emp.xsd'"/></xsl:attribute>

could be more easily written 
<Employees xsi:noNamespaceSchemaLocation="400_o_emp.xsd">



        <xsl:element name="Employee">
                                                <xsl:attribute 
name="employeeNumber">
                                                        <xsl:value-of 
select="EMPLOYEENUMBER"/>
                                                </xsl:attribute>
                                                <xsl:attribute name="lastName">
                                                        <xsl:value-of 
select="LASTNAME"/>
                                                </xsl:attribute>
                                                <xsl:attribute name="Initials">
                                                        <xsl:value-of 
select="INITIALS"/>
                                                </xsl:attribute>
                                                <xsl:attribute name="firstName">
                                                        <xsl:value-of 
select="FIRSTNAME"/>
                                                </xsl:attribute>
                                                <xsl:attribute name="gender">
                                                        <xsl:value-of 
select="GENDER"/>
                                                </xsl:attribute>
                                                <xsl:attribute 
name="dateOfBirth">
                                                        <xsl:if 
test="DATEOFBIRTH">
                                                                <xsl:if 
test="DATEOFBIRTH!=''">
                                                                        
<xsl:call-template name="FormatDate">
                                                                                
<xsl:with-param name="DateTime" select="DATEOFBIRTH" />
                                                                        
</xsl:call-template>
                                                                </xsl:if>
                                                        </xsl:if>
                                                </xsl:attribute>
                                        </xsl:element>
                                </xsl:for-each>
                        </xsl:element>


could more easily be written

<Employee
 employeeNumber="{EMPLOYEENUMBER}"
 lastName="{LASTNAME}"
Initials="{INITIALS}"
firstName="{FIRSTNAME}"
gender="{GENDER}"

<xsl:attribute name="dateOfBirth">
                <xsl:if test="not(DATEOFBIRTH='')">
                        <xsl:call-template name="FormatDate">
                                <xsl:with-param name="DateTime" 
select="DATEOFBIRTH" />
                        </xsl:call-template>
                </xsl:if>
</xsl:attribute>
</Employee>

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>