xsl-list
[Top] [All Lists]

Re: XML DIsplay

2002-10-23 12:05:09
jud013 wrote:
Is there a way of displaying two XML documents on dufferent web pages 
into your browser

Since you asked this on xsl-list, I assume you want to know how, in XSLT, to
access documents other than the main XML source. Just use the document
function.

<!-- $doc = root node of foo.xml -->
<xsl:variable name="doc" select="document('foo.xml')"/>

Then you can reference into foo.xml like
select="$doc/foo/bar/baz"

As for "displaying" such documents from "different web pages" in a browser,
I'm not sure what you mean. But you can use XSLT to generate HTML, if you
like. Or if you want to use the browser's XML rendering capabilities, you can
load up a dummy document like

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="getDocs.xsl"?>
<dummy/>

and then in getDocs.xsl you could do

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
  <xsl:template match="/">
    <!-- wrapper element needed to keep it well-formed -->
    <documents>
      <xsl:comment>FIRST DOCUMENT</xsl:comment>
      <xsl:copy-of select="document('foo.xml')"/>
      <xsl:comment>SECOND DOCUMENT</xsl:comment>
      <xsl:copy-of select="document('bar.xml')"/>
    </documents>
  </xsl:template>
</xsl:stylesheet>

If you need to pass the referenced filenames as parameters, this will require
either a server-side transformation (CGI, ASP, JSP, servlet or other mechanism
does the transform and delivers HTML to the browser), or the use of
vendor-specific scripting in the browser, such as what IE can use to do custom
invocations of MSXML for XML parsing and XSLT processing. See
msdn.microsoft.com for a copy of the MSXML FAQ and other related information.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

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



<Prev in Thread] Current Thread [Next in Thread>