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

Re: question about generate-id()

Subject: Re: question about generate-id()
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Fri, 6 Aug 2010 09:56:10 +0100
Re:  question about generate-id()
>> > 16.6.4
>> > There is no guarantee that a generated unique identifier will be
>> > distinct from any unique IDs specified in the source document.
>> >
>> > Yuk. IMHO that's a spec weakness. More constrained, surely
>> > it's not rocket science to implement.
>>
>> You could do it yourself
>
> Which would IMHO be a kludge to work round a spec weakness.
> Yes. Lots of ways to do it as this thread has shown.

If I've followed this thread, the problem is that generate-id() might
clash with some existing id in the source?  Mixing 2 ways of creating
the ids seems odd, and using a single consistent approach should make
the problem go away  Ultimately though, you should be validating the
result - you could do it an embedded xsd just for this check:

    <xsl:import-schema>
        <xs:schema>
            <xs:element name="foo">
                <xs:key name="my_id">
                    <xs:selector xpath=". | .//*"/>
                    <xs:field xpath="@id"/>
                </xs:key>
            </xs:element>
        </xs:schema>
    </xsl:import-schema>

    <xsl:template match="/">
        <xsl:result-document validation="strict">
            <foo id="a">
              <bar id="b"/>
              <baz id="a"/>
            </foo>
        </xsl:result-document>
    </xsl:template>

results in a (Saxon-EE) failure message containing:

Description: Non-unique value found for constraint my_id: "a"
Start location: 22:19
URL: http://www.w3.org/TR/xslt20/#err-XTTE1555




-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.