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

Re: Using id() when id and idref are in 2 different fi

Subject: Re: Using id() when id and idref are in 2 different files
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 13 Dec 2004 11:29:22 GMT
using id in dtd
  maybe when the document() function is used it breaks the element and
  attributes associations to the dtd that were in place when they were in
  their original location?

No. id would still work using document, so long as the file referenced
specifies a DTD. Using copy-of and node-set would break the association
as the idness isn't copied when a node is copued.

You have several options.
Firstly note that while IDREF/ID linking really is intended to be within
a document, XSLt doesn't know anything about IDREF and can take any
attribute value (or in fact any string) as the id to use.  however id()
(annd key()) only return nodes from the current document. So so long as
the document that has the id attributes has a DTD that has been read it
doesn't matter whether or not the attribute that has teh reference is in
the same document.

If your documents are 
<xsl:value-of name="doc1" select="document('1.xml')"/>
<xsl:value-of name="doc2" select="document('2.xml')"/>
<xsl:value-of name="doc3" select="document('3.xml')"/>
 
and you are in one of those documents (or anywhere else) with an
attribute ref that points at an id that is in one of those documents you
can do

<xsl:variable name="x" select="@ref"/>
<xsl:for-each select="$doc1|$doc2|$doc3">
  <xsl:apply-templates select="id($x)"/>
</xsl:for-each>

If the DTD isn't being read and you want to use key() you would use
exactly the same idiom, just replacing id($x) by key('id',$x) and
defining the id key with xsl:key.

On the other hand  if you just want to split up your document in to
multiple files but logically think of them as one document that is
exactly what XML entities are for, if your top level DTD defined

<!ENTITY doc1 SYSTEM "1.xml">
...

and  you top level file use

&doc1;

at the place you want to graft in that document to the main document
tree, XSLT (and any otehr XML application) would see the whole thing as
one document (and one ID scope) even though it is split over several
physical entities.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.