Subject: Re: [xsl] Getting Entity File Names From: Betty Harvey <betty@xxxxxxxxxx> Date: Thu, 23 Oct 2003 14:29:44 -0400 (EDT) |
Thanks! I think I will have to use XSLT 2 or another language. I am building a key for another document to point to locations in the external document. The data files don't belong to me so I have to point to information within the full document without the advantage of ID's. The only thing that really makes the data unique is the filenames and the titles within each file of the entities. Thanks again! Betty On Thu, 23 Oct 2003, David Carlisle wrote: > > I wrote > > > > The filename > > > of the fragment is the only identifier for over > > > 900 files. > > > > The design of xml entities is that the physical distribution of the > > document overfiles should not influence the logical document represented > > by the xml markup. Xpath (and so xslt) strictly adheres to this > > viewpoint and so the entities are fully expanded (leaving no record) as > > the input tree is constructed. > > > > You have two choices, edit your included documents so the top level > > element has an id or edit your including document so that the reference > > is marked, eg wrap each entity reference in an element. > > > > <fileref id="myfile">&myfile;</fileref> > > > > Which could be done using any regexp capable editor or perl or sed or > > something like that. > > > > David > > Which isn't strictly true. There is record left of the extrenal entity > as the base uri of the node, which is used for resolving relative uri in > the document() function, but not otherwise available in xslt/xpath 1. > > However it _is_ available in XPath2 so if you use saxon7 i think > (untested) you should be able to use base-uri() to access this. > > In XSLT1 you can not access the uri (ie file name) but you can detect > that you are in an external entity as document('') pulls in a different > file in this case (assuming that the entity is well formed if read as a > document, which need not be the case. > > In the following example there are three y elements and xslt reports > them as being in three different documents, as the generate-id are > different: > > > en1.xml: > > > <!DOCTYPE x [ > <!ENTITY a SYSTEM "ena.xml"> > <!ENTITY b SYSTEM "enb.xml"> > ]> > <x> > &a; > &b; > <y/> > </x> > > > > ena.xml: > > <y/> > > > enb.xml: > > <y/> > > > en1.xsl: > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > > > <xsl:template match="*"> > :<xsl:for-each select="ancestor::*">:</xsl:for-each> > <xsl:value-of select="name()"/> > <xsl:text> - </xsl:text> > <xsl:value-of select="generate-id(document('',.))"/> > <xsl:apply-templates/> > </xsl:template> > > </xsl:stylesheet> > > > > > > $ saxon en1.xml en1.xsl > <?xml version="1.0" encoding="utf-8"?> > :x - d1 > > ::y - d2 > > ::y - d3 > > ::y - d1 > > > > David > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Getting Entity File Names, David Carlisle | Thread | Re: [xsl] Getting Entity File Names, Wendell Piez |
RE: [xsl] Special characters in xsl, Archana Rao | Date | RE: [xsl] Special characters in xsl, Andreas L. Delmelle |
Month |