This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: how to refer to xml elements when using the document() function
- To: xsl-list at mulberrytech dot com
- Subject: Re: how to refer to xml elements when using the document() function
- From: Jiri Jirat <Jiri dot Jirat at idoox dot com>
- Date: Tue, 28 Nov 2000 08:15:10 +0100
- Organization: IDOOX
- References: <OFE75F0C3A.2F95C367-ONCA2569A5.001B78E9@dfat.gov.au>
- Reply-To: xsl-list at mulberrytech dot com
Hello Teresa,
try this (works with Saxon):
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="cmissions"><xsl:value-of select="document
('missions.xml')//missionspage/mission/country_code"/></xsl:variable>
<xsl:message>
Variable: <xsl:value-of select="$cmissions"/>
</xsl:message>
</xsl:template>
</xsl:stylesheet>
To see some functional examples, download
the XPointer or XLink tutorial from our site
and look at the XSLT:
http://www.zvon.org/index.php?nav_id=3
Best regards
Jirka
Teresa.Mairal-Barreu@dfat.gov.au wrote:
>
> I have been searching for the use of the document() function but I have
> found very little information and in some cases some of the examples didn't
> work when I tried them.
>
> I have to work with two different xml sources and I've been using document
> () but my question is what syntax to use to refer to individual elements
> belonging to 2 different input sources. I'm using xt and so far the only
> result I get is no result or the whole xml document is pasted into the
> output.
>
> I have tried:
>
> <xsl:variable name="cmissions"><xsl:value-of select="document
> ('../missions/missions.xml', /)"/></xsl:variable>
>
> and then refer to elements in the following way:
>
> <xsl:value-of select="$cmissions/mission/country_code"/>. This gives me an
> "unable to resolve node-set error".
>
> I also need to get the contents of <misscity> for each <hom_country> ie
> hom_country_code and hom_country have to be compared and the corresponding
> city has to be part of the output. How do I refer to each hom_country and
> country_code?
>
> I'd appreciate it if you could help.
>
> homs.xml
> --------------
> <homs_list>
> <hom>
> <hom_type>abc</hom_type>
> <hom_name>xyz</hom_name>
> <hom_country_code>fr</hom_country_code>
> </hom>
> <hom>
> .....
> </hom>
> <homs_list>
>
> missions.xml
> -------------------
> <missionspage>
> <mission>
> <country_code>fr</country_code>
> <missaddress>
> <misstreet>xyz</misstreet>
> <misscity>abc</misscity>
> </missaddress>
> </mission>
> <mission>
> ...
> </mission>
> </missionspage>
>
> Teresa
>
> _________________________________________
> Teresa Mairal Barreu
> Public Diplomacy Division
> Images of Australia Branch
> International Media Strategies Section
> Australian Department of Foreign Affairs and Trade
>
> teresa.mairal-barreu@dfat.gov.au
> http://www.dfat.gov.au
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
--
<name firstName="Jirka" surname="Jirat"/>
<mail> jiratj@idoox.com </mail>
<support> http://www.zvon.org </support>
<zvonMailingList> http://www.zvon.org/index.php?nav_id=4
</zvonMailingList>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list