Page 1 of 1

select child element of xPath with axes

Posted: Sat Dec 26, 2009 7:34 pm
by metalhammer
Hi,

I want the title of my html file to be the value of a grandchild element from a xPath with axes.

That doesn't sounds as a clear explanation, but I'll try to clear it out.

This is a shortened version of my xml file:

Code: Select all

<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<?xml-stylesheet type="text/xsl" href="XMP_omvormen.xslt"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.2-c063 53.352624, 2008/07/30-18:05:41 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<rdf:Description rdf:about=""
xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreateDate>2007-07-04T16:36:14+02:00</xmp:CreateDate>
<xmp:CreatorTool>Esko PackEdge 7.0 NT Jun 26 2007, build 627</xmp:CreatorTool>
<xmp:MetadataDate>2007-07-04T16:36:16+02:00</xmp:MetadataDate>
<xmp:ModifyDate>2007-07-04T16:36:16+02:00</xmp:ModifyDate>
<xmp:Rating>4</xmp:Rating>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:format>application/pdf</dc:format>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">esko pdf example file </rdf:li>
</rdf:Alt>
</dc:description>
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">EskoArtwork XMP example file</rdf:li>
</rdf:Alt>
</dc:title>
<dc:creator>
<rdf:Seq>
<rdf:li>EskoArtwork</rdf:li>
</rdf:Seq>
</dc:creator>
<dc:subject>
<rdf:Bag>
<rdf:li>Esko</rdf:li>
<rdf:li>Artwork</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>

</x:xmpmeta>
<?xpacket end="w"?>
I want "EskoArtwork XMP example file" to be the title of my html file.

I've tried the following code, but it doesn't work.

Code: Select all

				<title>
<xsl:value-of select="rdf:Description[
namespace::*[.='http://purl.org/dc/elements/1.1/']
]/dc:title/rdf:Alt/rdf:li"/>
</title>

Re: select child element of xPath with axes

Posted: Mon Dec 28, 2009 12:41 pm
by george
Please post a working sample to allow to easy reproduce the issue. Your XML fragment is not wellformed and the XSLT fragment is out of context and the problem is probably exactly in the part that is missing.

Your code works for me putting it in the right template and with the appropriate namespace declarations, after I corrected the XML file:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/" version="1.0">
<xsl:template match="rdf:RDF">
<title>
<xsl:value-of select="rdf:Description[namespace::*[.='http://purl.org/dc/elements/1.1/']]/dc:title/rdf:Alt/rdf:li"/>
</title>
</xsl:template>
</xsl:stylesheet>

Code: Select all


<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<?xml-stylesheet type="text/xsl" href="XMP_omvormen.xslt"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.2-c063 53.352624, 2008/07/30-18:05:41 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreateDate>2007-07-04T16:36:14+02:00</xmp:CreateDate>
<xmp:CreatorTool>Esko PackEdge 7.0 NT Jun 26 2007, build 627</xmp:CreatorTool>
<xmp:MetadataDate>2007-07-04T16:36:16+02:00</xmp:MetadataDate>
<xmp:ModifyDate>2007-07-04T16:36:16+02:00</xmp:ModifyDate>
<xmp:Rating>4</xmp:Rating>
</rdf:Description>
<rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:format>application/pdf</dc:format>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">esko pdf example file </rdf:li>
</rdf:Alt>
</dc:description>
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">EskoArtwork XMP example file</rdf:li>
</rdf:Alt>
</dc:title>
<dc:creator>
<rdf:Seq>
<rdf:li>EskoArtwork</rdf:li>
</rdf:Seq>
</dc:creator>
<dc:subject>
<rdf:Bag>
<rdf:li>Esko</rdf:li>
<rdf:li>Artwork</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>

</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
Regards,
George

Re: select child element of xPath with axes

Posted: Mon Dec 28, 2009 1:53 pm
by metalhammer
I solved it, the problem was with the template.

I changed

Code: Select all


	<xsl:template match="/">
to

Code: Select all


	<xsl:template match="rdf:RDF">
like in your code.

Thanks for your help!