Subject: Re: [xsl] Generating Unique Identifier From: Lighton Phiri <lighton.phiri@xxxxxxxxx> Date: Sat, 22 Oct 2011 21:49:16 +0200 |
On 22 October 2011 21:31, G. Ken Holman <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote: > At 2011-10-22 21:26 +0200, Lighton Phiri wrote: >> >> I have two different files that I am using to generate html files. One >> of the html files references the other html file using an anchor ( <a >> name="uniqueid" /> ) >> >> I am looking for a way to generate the unique name. I cannot use >> generate-id() as the nodes are located in different files. > > I don't see why you cannot use generate-id(). During a transformation the > identity of all nodes of all trees is unique. You simply reach into the > tree with your target node and get its generated identifier. > > You say you are using XSLT 1.0 (it is easier in XSLT 2.0), so you can do: > > <xsl:for-each select="$other-file"> > ... make your way to the element ... > <xsl:value-of select="generate-id()"/> > </xsl:for-each> > >> I have >> tried normalising the content, but I end up with duplicates when I try >> to replace spaces and other special characters. Any ideas on how best >> I can sort this out? >> >> File 1 >> <file> >> <keyword>the-word_</keyword> >> <keyword>-the word</keyword> >> <keyword>!the&word</keyword> >> <resources> >> <resource>xxxxx</resource> >> <resource>xxxxx</resource> >> </resources> >> </file> >> >> >> File 2 >> <file> >> <resource> >> <id>xxxxx</id> >> <title>xxxxx</title> >> <description>xxxxx</ >> description> >> <keywords/> >> <key>the-word</key> >> <key>-the-word</key> >> <key>!the&word</key> >> </keyword> >> </resource> >> </file> >> >> Desired output >> >> >> <html> >> : >> <body> >> File2 link is <a name="UNIQUEID" /> >> </body> >> : >> </html> > > Which is your input file and which is the referenced file? How is the > referencing done in order to look up your target match? > > . . . . . . . . . Ken > > -- > Contact us for world-wide XML consulting and instructor-led training > Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ > G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx > Google+ profile: https://plus.google.com/116832879756988317389/about > Legal business disclaimers: http://www.CraneSoftwrights.com/legal > > Sorry if my question was not very clearly, but I have two seperate stylesheets that each generate html files. File 1 html output has content that is referenced by File 2 output. The problem is that I am unable to find a suitable way of generating. I was hoping there could perhaps be a way of generating a UNIQUE identifier common to both output files other than using generate-id(). -- Lighton Phiri lighton.phiri@xxxxxxxxxxxxxxxx http://lightonphiri.org/ @lightonphiri
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Generating Unique Identif, G. Ken Holman | Thread | Re: [xsl] Generating Unique Identif, G. Ken Holman |
[xsl] Seek an elegant way to remove, Costello, Roger L. | Date | Re: [xsl] Generating Unique Identif, G. Ken Holman |
Month |