[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Add in extra level to XML file

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

The following stylesheet:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Properties">
	<Properties>
		<xsl:apply-templates/>
	</Properties>
</xsl:template>

<xsl:template match="Property">
	<Property><xsl:attribute name="num"><xsl:value-of
select="@num"/></xsl:attribute>
		<xsl:attribute name="LicenseNumber"><xsl:value-of
select="LicenseNumber"/></xsl:attribute>
		<PropertyAddress>
			<xsl:apply-templates/>
		</PropertyAddress>
	</Property>
</xsl:template>

<xsl:template match="LicenseNumber"/>

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

</xsl:stylesheet>

Gives this output

<?xml version='1.0' ?>
<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>
            <OwnerId>987634</OwnerId>
    </PropertyAddress></Property>
</Properties>

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

Spencer


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
monitoring.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.