Re: [xsl] Add in extra level to XML file

Subject: Re: [xsl] Add in extra level to XML file
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Fri, 24 Feb 2006 07:51:22 -0800
Hi Elaine,

The following stylesheet:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"

<xsl:template match="Properties">

<xsl:template match="Property">
	<Property><xsl:attribute name="num"><xsl:value-of
		<xsl:attribute name="LicenseNumber"><xsl:value-of

<xsl:template match="LicenseNumber"/>

<xsl:template match="@*|node()">
	<xsl:apply-templates select="@*|node()"/>


Gives this output

<?xml version='1.0' ?>
     <Property num="1" LicenseNumber="99999"><PropertyAddress>

            <AddressLine2>1 Grove Place</AddressLine2>
            <PostCode>AB22 2HY</PostCode>

When run against Saxon 8.1.1.... Hope this helps,


On 2/24/06, Elaine STEWART <ELAINEST@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
> I have an XML file that looks like the following...
> <Properties>
>       <Property num="1">
>              <LicenseNumber>99999</LicenseNumber>
>              <AddressLine1>Sankos</AddressLine1>
>              <AddressLine2>1 Grove Place</AddressLine2>
>              <AddressLine3>Rosemount</AddressLine3>
>              <Town>Bradford</Town>
>              <PostCode>AB22 2HY</PostCode>
>              <OwnerId>987634</OwnerId>
>      </Property>
> </Properties
> but I would like it to look like this...
> <Properties>
>       <Property num="1" LicenseNumber="99999">
>              <PropertyAddress>
>                    <AddressLine1>Sankos</AddressLine1>
>                    <AddressLine2>1 Grove Place</AddressLine2>
>                    <AddressLine3>Rosemount</AddressLine3>
>                    <Town>Bradford</Town>
>                    <PostCode>AB22 2HY</PostCode>
>              </PropertyAddress>
>              <OwnerId>987634</OwnerId>
>      </Property>
> </Properties>
> It's the insert of the <PropertyAddress> & </PropertyAddress> that I'm
> having a problem with.
> Can someone help me with a solution.
> Thanks
> Elaine Stewart
> Systems Analyst
> Continuous Improvement Service
> Telephone: 01224 523608
> IMPORTANT NOTICE: This e-mail (including any attachment to it) is
confidential, protected by copyright and may be privileged.  The information
contained in it should be used for its intended purposes only.  If you receive
this e-mail in error, notify the sender by reply e-mail, delete the received
e-mail and do not make use of, disclose or copy it. Whilst we take reasonable
precautions to ensure that our emails are free from viruses, we cannot be
responsible for any viruses transmitted with this e-mail and recommend that
you subject any incoming e-mail to your own virus checking procedures.  Unless
related to Council business, the opinions expressed in this e-mail are those
of the sender and they do not necessarily constitute those of Aberdeen City
Council. Unless we expressly say otherwise in this e-mail or its attachments,
neither this e-mail nor its attachments create, form part of or vary any
contractual or unilateral obligation.
> Aberdeen City Council's incoming and outgoing e-mail is subject to regular

Current Thread