One way to do it is to apply an identity transform to your instance :
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- ignore these elements -->
<xsl:template match="AreaLightingMaintenance | Async
| uploadEnrolments | v1.0">
<xsl:apply-templates/>
</xsl:template>
or , if you know for sure, the <Result> is all you'll ever need :
<xsl:template match="Data/*[not(self::Result)]">
<xsl:apply-templates/>
</xsl:template>
You'll not use Xerces explicitly if you go this route
Regards
Sergey Beryozkin
----- Original Message -----
From: "DePaul, James" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 23, 2002 9:49 PM
Subject: Removing Parent Elements...
Can someone recommend a solution to the following problem:
We are given a data structure (as shown below) and we need to 'transform' it
into another retulting structure. Here is the input XML:
<?xml version="1.0" encoding="UTF-8"?>
<OperationResult>
<Data>
<AreaLightingMaintenance>
<Async>
<uploadEnrolments>
<v1.0>
<Result>
<OutputFileName>Text</OutputFileName>
<ExceptionFileName>Text</ExceptionFileName>
<CustomerResultFileName>Text</CustomerResultFileName>
<PremiseResultFileName>Text</PremiseResultFileName>
<PostalAddressResultFileName>Text</PostalAddressResultFileName>
<ServiceResultFileName>Text</ServiceResultFileName>
<CustomerExceptionReportFileName>Text</CustomerExceptionReportFileName>
<PremiseExceptionReportFileName>Text</PremiseExceptionReportFileName>
<PostalAddressExceptionReportFileName>Text</PostalAddressExceptionReportFile
Name>
<ServiceExceptionReportFileName>Text</ServiceExceptionReportFileName>
<PostalAddressFileName>Text</PostalAddressFileName>
<PremiseOutputFileName>Text</PremiseOutputFileName>
<ServiceOrderExceptionFileName>Text</ServiceOrderExceptionFileName>
<MeterReadingsExceptionFileName>Text</MeterReadingsExceptionFileName>
<StatusFileName>Text</StatusFileName>
<AcknowledgementFileName>Text</AcknowledgementFileName>
</Result>
</v1.0>
</uploadEnrolments>
</Async>
</AreaLightingMaintenance>
</Data>
</OperationResult>
The final structure that we need to achieve at appears as follows:
<?xml version="1.0" encoding="UTF-8"?>
<OperationResult>
<Data>
<Result>
<OutputFileName>Text</OutputFileName>
<ExceptionFileName>Text</ExceptionFileName>
<CustomerResultFileName>Text</CustomerResultFileName>
<PremiseResultFileName>Text</PremiseResultFileName>
<PostalAddressResultFileName>Text</PostalAddressResultFileName>
<ServiceResultFileName>Text</ServiceResultFileName>
<CustomerExceptionReportFileName>Text</CustomerExceptionReportFileName>
<PremiseExceptionReportFileName>Text</PremiseExceptionReportFileName>
<PostalAddressExceptionReportFileName>Text</PostalAddressExceptionReportFile
Name>
<ServiceExceptionReportFileName>Text</ServiceExceptionReportFileName>
<PostalAddressFileName>Text</PostalAddressFileName>
<PremiseOutputFileName>Text</PremiseOutputFileName>
<ServiceOrderExceptionFileName>Text</ServiceOrderExceptionFileName>
<MeterReadingsExceptionFileName>Text</MeterReadingsExceptionFileName>
<StatusFileName>Text</StatusFileName>
<AcknowledgementFileName>Text</AcknowledgementFileName>
</Result>
</Data>
</OperationResult>
So we are essentially looking to position on the <Result> tag and delete the
four immediate Parent Nodes (<AreaLightingMaintenance>, <Async>,
<uploadEnrolments>, and <v1.0> - respectively).
Is there a code sample for fining a specific Child Node and working
backwards to delete some of its Parent Elements?! Or maybe there is yet
another solution that someone could recommend?!
Thanks,
James
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]