xsl-list
[Top] [All Lists]

Re: Add in extra level to XML file

2006-02-24 08:51:22
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(_at_)aberdeencity(_dot_)gov(_dot_)uk> 
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.


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



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