Subject: Re: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Using id() when id and id, Chris Matchett | Thread | RE: [xsl] Using id() when id and id, Chris Matchett |
RE: [xsl] Using id() when id and id, Michael Kay | Date | Re: [xsl] Extracting the grouping f, Kevin Jones |
Month |