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 April 28th, 2008, 07:32 PM
Registered User
 
Join Date: Apr 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default xslt to update only a portion of a page

Is it possible to use xml and xslt stylesheet to only update a specific section of a page? ie: a div within the dom?

I could have sworn I've done this before but have lost my source files from a couple years back. Isn't this possible via javascript?
Marry your xml and xslt files and whatever the generated data is innerHTML into a div or whatever you want? Thanks guys!!
 
Old April 28th, 2008, 07:42 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT doesn't update the input document, it transforms it to an output document, so if some of the input is to remain unchanged then it needs to be explicitly copied to the output. It's often convenient to do this using an identity template:

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

augmented by template rules that match the part of the document that you want to modify.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 28th, 2008, 09:42 PM
Registered User
 
Join Date: Apr 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mr. Kay,

Thank you for the response!
I apologize because I certainly didn't ask this question the right way as I often tend to do :-/
I was discussing today with someone at work of how we could use an xml feed we're getting. I thought of using xslt to parse it and spew (such a nice way of saying it huh?) it onto a regular 'ol Joe html page. Mind you...the html page was developed with straight html.

I hope I asked my question better this time. By the way, just ordered your book from a1books here in NJ. There's not another addition coming out anytime soon is there? Just so I don't kick myself in the butt in a month or two when it comes out heh


Quote:
quote:Originally posted by mhkay
 XSLT doesn't update the input document, it transforms it to an output document, so if some of the input is to remain unchanged then it needs to be explicitly copied to the output. It's often convenient to do this using an identity template:

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

augmented by template rules that match the part of the document that you want to modify.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 29th, 2008, 02:55 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You can transform your XML feed into a portion of HTML and then use Javascript to update your document, provided your client browser has the facilities to load an XSLT processor.

And the latest version of Michael's book is just coming out now - "XSLT 2.0 and XPath 2.0 Programmer Reference" ISBN 978-0470192740.

/- Sam Judson : Wrox Technical Editor -/
 
Old April 29th, 2008, 06:29 AM
Registered User
 
Join Date: Apr 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I KNEW IT!!! I should have waited. It's ok I can cancel :) Thanks guys really!
I'm really looking forward to contributing to the forums.

Quote:
quote:Originally posted by samjudson
 You can transform your XML feed into a portion of HTML and then use Javascript to update your document, provided your client browser has the facilities to load an XSLT processor.

And the latest version of Michael's book is just coming out now - "XSLT 2.0 and XPath 2.0 Programmer Reference" ISBN 978-0470192740.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML portion of aspx file SKhna ASP.NET 2.0 Basics 3 March 25th, 2008 10:52 AM
Extracting portion of XML ** Need help asap** aintvoguish XSLT 3 December 20th, 2007 09:12 AM
Want to print some portion of the web page. jigu_2811 C# 1 October 17th, 2006 08:16 AM
In Access - look at portion of string usvinyl Access 1 September 23rd, 2004 03:06 PM





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