At 2008-07-19 11:28 -0400, Philip Vallone wrote:
I have a project were I take about 800 files and transform them into one .fo
document (create a pdf). The files are authored independent of each other
(stand alone) which are validated against a schema (independently). If there
is a duplicate @id attribute, the validator will tell me. However, the @ids
need to be unique across all files processed by the collection function. If
they are not, my resulting .fo will have duplicate @ids, which cause FOP to
halt.
This is the use case for generate-id() ... in my XSL classes I take
the students through the two steps of ensuring unique identifiers in
aggregating XML source documents to a single XSL-FO result document:
Assuming the current node is the element with the @id attribute, the
unique anchor in the FO tree is created using something along the lines
of:
<block id="{generate-id(.)}">
Assuming you are at the element that is making the reference with @idref
and you have a DTD declaration for the ID property of the target element,
the link is created using:
<basic-link internal-destination="{generate-id(id(@idref))}">
... or you can just move your context to the element with the @id
attribute and do:
<basic-link internal-destination="{generate-id(.)}">
I am looking for a way to (query or xslt 2.0) to check for duplicate @id's
values across all files with the collection function. This would be a
pre-production check.
Not needed if you choose to use generate-id() ... it is specified to
guarantee uniqueness across all nodes when it is called for any node
in the node tree, and within one run of the stylesheet you always get
the same value returned for any given node.
It is an opaque value, alpha-numeric, that you use without analyzing
its value because every processor will give you something different
... but you can add your own ".","-" or "_" character to it if you
need to make multiple unique anchors for one node.
The value is not guaranteed to be the same the next time you run the
stylesheet on the node tree, even if the node tree is unchanged. The
value cannot be reliably sorted or relied on for any purpose other
than being unique.
By using generate-id() you never need to worry which values are being
used by your authors, provided within each XML file they are being
used properly.
I hope this helps.
. . . . . . . . . . Ken
--
Upcoming XSLT/XSL-FO hands-on courses: Wellington, NZ 2009-01
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds: publicly-available developer resources and training
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--