[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Populating keys with values from other documents
On 29/06/2010 19:31, Ashton, Andrew wrote:
the code posted appeared to use @xml:id in both documents rather than @ref ???I am trying to look up a value in an XML document (people.xml) based on a @ref attribute in my primary document (source.xml). I know that the @ref values in source.xml will match the @xml:id values in people.xml. I can do something like this:
probably better to write that as <xsl:variable name="uriRef" select="ancestor::*[@xml:id][1]/@xml:id"/. <xsl:variable name="person" select="document('file:///people.xml')//person[@xml:id=concat($var, '')]"/>
where key is defined by <xsl:key name="p" match="person" use="@xml:id"/> If you are using xslt1, you need to wrap the whole of this part of the code in <sl;for-each select="document('file:///people.xml')"> ... <xsl:variable name="person" select="key('p',$var)"/> ... </xsl:for-each> , <xsl:if test="$person/residence/country"> <span about="ont:place#{$uriRef}" property="foaf:based_near"> <xsl:value-of select="$person/residence/country"/> </span> </xsl:if> </xsl:template>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|