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

Re: using document() to read HTML

Subject: Re: using document() to read HTML
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 3 Feb 2001 11:58:54 +0000
how to read html document
Hi Rosa,

> thanx to David for the hyperlink replies. Here's another one: when u
> read in a HTML page say using document(top.htm) - don't know any
> other way - , I presume it's like a pointer pointing to the
> beginning node of that file. Because I want sections of the HTM file
> or even the whole HTM file to be in front of some HTML which will be
> translated by XSL.

If you do:

  <xsl:copy-of select="document('top.htm')" />

then you will get a copy of the entire file at the point where you
place the instruction.

If you're interested in a specific part of that document, then you can
select nodes in it using an XPath in just the same way as you can
select nodes in the source XML document.  For example:

  <xsl:copy-of select="document('top.htm')/*/BODY/TABLE[1]/TR" />

will copy all the TR elements of the first TABLE element within the
BODY element of your HTML document.

If you want to determine what to copy on the fly, then you can apply
templates to the external HTML document in just the same way as you
can to the source document.  So you could do:

  <xsl:apply-templates select="document('top.htm')/*" />

and then have templates that perform the relevant copying:

<xsl:template match="TR">
   <xsl:copy-of select="." />
</xsl:template>

One thing to watch out for if you take this last approach is that
there might be clashes between templates you're using for the main
source XML document and the templates you want to use for the external
HTML document. If this is a problem, it might be best to use modes to
distinguish between the two.  For example:

  <xsl:apply-templates select="document('top.htm')/*" mode="insert" />

and then:

<xsl:template match="TR" mode="insert">
   <xsl:copy-of select="." />
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.