I am having a bit of trouble fighting through a namespace issue. I have the follow input document

<?xml version="1.0" ?> 
<ns:CustomObject3WS_CustomObject3QueryPage_Output xmlns:ns="urn:crmondemand/ws/customobject3/10/2004">
    <ns:LastPage>true</ns:LastPage> 
    <ListOfCustomObject3 xmlns="urn:/crmondemand/xml/customObject3">
        <CustomObject3>
            <AccountExternalSystemId /> 
            <AccountId>ADOA-3CN5XR</AccountId> 
            <AccountName /> 
            <CreatedBy>Olga CLEMENDOT, 09/08/2009 13:59:17</CreatedBy> 
            <CreatedDate>09/08/2009 13:59:17</CreatedDate> 
            <CustomObject3Id>ADOA-3I66LA</CustomObject3Id> 
            <ExternalSystemId>ADOA-3CN5XR</ExternalSystemId> 
            <ModifiedBy>Véronique CHINA, 06/22/2010 14:34:53</ModifiedBy> 
            <Name>ADOA-3CN5XR</Name> 
            <Type /> 
            <ModifiedDate>06/22/2010 14:34:53</ModifiedDate> 
            <stZ_DS1_ACCOUNT_CUSTMO>SIM35200031</stZ_DS1_ACCOUNT_CUSTMO> 
            <stZ_DS1_ACCOUNT_ID>AUTSIM35200031</stZ_DS1_ACCOUNT_ID> 
            <stZ_DS1_Account_First_Origin>SIMULIA 2007</stZ_DS1_Account_First_Origin> 
            <ListOfAccount>
                <Account>
                    <AccountId>AAXA-GYYE0</AccountId> 
                    <ExternalSystemId>100000000000001</ExternalSystemId> 
                    <Name>AVL LIST GMBH [100000000000001]</Name> 
                </Account>
            </ListOfAccount>
        </CustomObject3>
    </ListOfCustomObject3>
</ns:CustomObject3WS_CustomObject3QueryPage_Output>

which I am running through the following translation:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns="urn:/crmondemand/xml/customObject3"
    xpath-default-namespace="urn:/crmondemand/xml/customObject3">
    
    <xsl:output indent="yes"/>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="CustomObject3">
        <xsl:apply-templates select="ListOfAccount/Account"/>
    </xsl:template>
    
    <xsl:template match="Account">
        <CustomObject3>
            <xsl:apply-templates select="AccountId|Name|ExternalSystemId"/>
            <xsl:copy-of select="../../ExternalSystemId"/>
            <xsl:copy-of select="../../CreatedBy"/>
            <xsl:copy-of select="../../CreatedDate"/>
            <xsl:copy-of select="../../CustomObject3Id"/>
            <xsl:copy-of select="../../ModifiedBy"/>
            <xsl:copy-of select="../../ModifiedDate"/>
            <xsl:copy-of select="../../Type"/>
            <xsl:copy-of select="../../stZ_DS1_ACCOUNT_CUSTMO"/>
            <xsl:copy-of select="../../stZ_DS1_ACCOUNT_ID"/>
            <xsl:copy-of select="../../stZ_DS1_Account_First_Origin"/>
        </CustomObject3>
    </xsl:template>
    
    <xsl:template match="Name">
        <xsl:element name="Account{name()}">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>
    <xsl:template match="ExternalSystemId">
        <xsl:element name="Account{name()}">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>
    
</xsl:stylesheet>

This produces the following output:

<?xml version="1.0" encoding="UTF-8"?>
<ns:CustomObject3WS_CustomObject3QueryPage_Output xmlns:ns="urn:crmondemand/ws/customobject3/10/2004">
    <ns:LastPage>true</ns:LastPage> 
    <ListOfCustomObject3 xmlns="urn:/crmondemand/xml/customObject3">
        <CustomObject3>
         <AccountId>AAXA-GYYE0</AccountId>
         <AccountExternalSystemId>100000000000001</AccountExternalSystemId>
         <AccountName>AVL LIST GMBH [100000000000001]</AccountName>
         <ExternalSystemId>ADOA-3CN5XR</ExternalSystemId>
         <CreatedBy>Olga CLEMENDOT, 09/08/2009 13:59:17</CreatedBy>
         <CreatedDate>09/08/2009 13:59:17</CreatedDate>
         <CustomObject3Id>ADOA-3I66LA</CustomObject3Id>
         <ModifiedBy>Véronique CHINA, 06/22/2010 14:34:53</ModifiedBy>
         <ModifiedDate>06/22/2010 14:34:53</ModifiedDate>
         <Type/>
         <stZ_DS1_ACCOUNT_CUSTMO>SIM35200031</stZ_DS1_ACCOUNT_CUSTMO>
         <stZ_DS1_ACCOUNT_ID>AUTSIM35200031</stZ_DS1_ACCOUNT_ID>
         <stZ_DS1_Account_First_Origin>SIMULIA 2007</stZ_DS1_Account_First_Origin>
      </CustomObject3>
    </ListOfCustomObject3>
</ns:CustomObject3WS_CustomObject3QueryPage_Output>

My problem is that I need to force the output for <ListOfCustomObject3> without the namespace reference as it is causing me downstream problems. Thanks in advance for any suggestions.

try this hope will work.

<xsl:template match="ListOfCustomObject3/@xmlns"/>

mohan

Thanks for the response ... it did not seem to have any affect.

You need to use copy-of with copy-namespaces="no":

<xsl:copy-of copy-namespaces="no"/>

Additionally, you have to set the empty namespace:

<xsl:template match="Account">
   <CustomObject3 xmlns="">
       ...
   </CustomObject3>
</xsl:template>

Finally, use local-name() instead of name(), e.g.:

<xsl:element name="Account{local-name()}">
    <xsl:value-of select="."/>
</xsl:element>

This will probably not solve all of your problems, but it will bring you some steps closer to what you want...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.