xsl-list
[Top] [All Lists]

[xsl] Adding an element of a specific type

2006-10-18 07:11:13
Hi all,

How do I add an element of a specific type to the output.

This is my input:

<?xml version="1.0" encoding="UTF-8"?>
<ns1:P xmlns:ns1="somenamespace">
    <ns1:X>some data</ns1:X>
    <ns1:O>
        <ns1:C>
            ...
        </ns1:C>
    </ns1:O>
</ns1:P>

I want to get the structure below. The schema does not have element Q,
but only has complexType Q_Type:

<?xml version="1.0" encoding="UTF-8"?>
<ns1:Q type="ns1:Q_Type" xmlns:ns1="somenamespace">
    <ns1:C>
            ...
    </ns1:C>
</ns1:P>

I tried something like this, but that does not seem to work:

<xsl:template match="ns1:O">
    <xsl:element name="ns1:Q">
       <xsl:attribute name="xsi:type">ns1:Q_Type</xsl:attribute>
       <xsl:apply-templates select="ns1:C" >
    </xsl:element>
</xsl:template> 

The processor starts complaining about the namespace of the type, which
I kind of expected already.
Haven't got a clue though how to fix this.

(sorry, but I am not sure which processor I have, since it is embedded
in an existing application)

Best regards,
Peter


This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

--~------------------------------------------------------------------
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>