Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2006, 04:17 AM
Authorized User
 
Join Date: Jun 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ignoring Namespace Pt2

Hi there,

I have a XSLT that basically replicates the source XML and appends an element at the end of the source XML that contains the time stamp that the source XML was processed by the XSLT.

However, the source XML can be any of any structure, for example, I could have a source XML that contains a structure having details about an inventory of kitchen items and I could have another source XML that have a structure with details of car spare parts.

Each of these different source XML contains a namespace specific to that structure.

I wish to ignore the namespace of the source XML and basically make an exact copy of the source XML and appending the timestamp in an element at the end of the source XML. Is this possible?

Thanks

 
Old June 19th, 2006, 05:08 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, you can use the usual design pattern of a modified identity transform:

<xsl:template match="*">
  <xsl:copy>
  <xsl:copy-of select="@*"/>
  <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<xsl:template match="/*">
  <xsl:copy-of select="*"/>
  <time><xsl:value-of select="$timestamp"/></time>
</xsl:template>

If you want <time> to be in the same namespace as its parent element, create it using <xsl:element name="time" namespace="{namespace-uri(.)}"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ignoring first element using for-each amhicraig XSLT 1 December 4th, 2007 05:41 PM
Ignoring in False clause? gabster XSLT 2 September 7th, 2007 08:29 AM
ignoring/skipping returns (linebreaks) TPP XSLT 2 November 22nd, 2006 02:59 PM
my stylesheet is ignoring nodes gonzalocordero XSLT 8 June 30th, 2006 09:17 PM
Ignoring namespace in source XML Chamkaur XSLT 1 June 16th, 2006 03:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.