xPath problem
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 26
- Joined: Tue Dec 22, 2009 2:40 pm
xPath problem
Post by metalhammer »
Hi,
I'm having a similar problem to my problem here: http://www.oxygenxml.com/forum/topic4878.html
In my xml file there is a list with all inks used in a document.
There also is a list with the ink coverage of each ink.
The ink coverage list doesn't has the corresponding ink names, but it uses the same sequence as the inks list.
In my output html file I want the ink name with the corresponding coverages.
I tried building a xPath based on the previously mentioned topic, but it won't work.
My xml:
My xslt:
I'm having a similar problem to my problem here: http://www.oxygenxml.com/forum/topic4878.html
In my xml file there is a list with all inks used in a document.
There also is a list with the ink coverage of each ink.
The ink coverage list doesn't has the corresponding ink names, but it uses the same sequence as the inks list.
In my output html file I want the ink name with the corresponding coverages.
I tried building a xPath based on the previously mentioned topic, but it won't work.
My xml:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.1.1">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/"
xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/">
<egGr:inks>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<egInk:name>cyan</egInk:name>
<egInk:type>process</egInk:type>
<egInk:book>process</egInk:book>
<egInk:egname>cyan</egInk:egname>
<egInk:frequency>120.</egInk:frequency>
<egInk:angle>22.5</egInk:angle>
<egInk:dotshape>R</egInk:dotshape>
<egInk:r>0.</egInk:r>
<egInk:g>.6491146478</egInk:g>
<egInk:b>.9086514743</egInk:b>
<egInk:attribute>normal</egInk:attribute>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>magenta</egInk:name>
<egInk:type>process</egInk:type>
<egInk:book>process</egInk:book>
<egInk:egname>magenta</egInk:egname>
<egInk:frequency>120.</egInk:frequency>
<egInk:angle>52.5</egInk:angle>
<egInk:dotshape>R</egInk:dotshape>
<egInk:r>.921078013</egInk:r>
<egInk:g>.1982994402</egInk:g>
<egInk:b>.5299102447</egInk:b>
<egInk:attribute>normal</egInk:attribute>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>yellow</egInk:name>
<egInk:type>process</egInk:type>
<egInk:book>process</egInk:book>
<egInk:egname>yellow</egInk:egname>
<egInk:frequency>120.</egInk:frequency>
<egInk:angle>7.5</egInk:angle>
<egInk:dotshape>R</egInk:dotshape>
<egInk:r>1.</egInk:r>
<egInk:g>.9642572</egInk:g>
<egInk:b>0.</egInk:b>
<egInk:attribute>normal</egInk:attribute>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>black</egInk:name>
<egInk:type>process</egInk:type>
<egInk:book>process</egInk:book>
<egInk:egname>black</egInk:egname>
<egInk:frequency>120.</egInk:frequency>
<egInk:angle>82.5</egInk:angle>
<egInk:dotshape>R</egInk:dotshape>
<egInk:r>.1870992878</egInk:r>
<egInk:g>.1778713106</egInk:g>
<egInk:b>.1984996809</egInk:b>
<egInk:attribute>normal</egInk:attribute>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>275</egInk:name>
<egInk:type>pantone</egInk:type>
<egInk:book>pms1000c</egInk:book>
<egInk:egname>275</egInk:egname>
<egInk:frequency>175.</egInk:frequency>
<egInk:angle>45.</egInk:angle>
<egInk:dotshape>R</egInk:dotshape>
<egInk:r>.1269799303</egInk:r>
<egInk:g>.09725712993</egInk:g>
<egInk:b>.3518643488</egInk:b>
<egInk:attribute>normal</egInk:attribute>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>Artios Cut</egInk:name>
<egInk:type>designer</egInk:type>
<egInk:book>designer</egInk:book>
<egInk:egname>Artios Cut</egInk:egname>
<egInk:frequency>120.</egInk:frequency>
<egInk:angle>45.</egInk:angle>
<egInk:dotshape/>
<egInk:r>.4669890404</egInk:r>
<egInk:g>0.</egInk:g>
<egInk:b>.05328740552</egInk:b>
<egInk:attribute>technical</egInk:attribute>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>Artios Crease</egInk:name>
<egInk:type>designer</egInk:type>
<egInk:book>designer</egInk:book>
<egInk:egname>Artios Crease</egInk:egname>
<egInk:frequency>120.</egInk:frequency>
<egInk:angle>45.</egInk:angle>
<egInk:dotshape/>
<egInk:r>.8685721159</egInk:r>
<egInk:g>.1915872991</egInk:g>
<egInk:b>.07788107544</egInk:b>
<egInk:attribute>technical</egInk:attribute>
</rdf:li>
</rdf:Seq>
</egGr:inks>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:egInkCovL="http://ns.esko-graphics.com/inkcovlist/1.0/"
xmlns:egInkCov="http://ns.esko-graphics.com/inkcov/1.0/">
<egInkCovL:coverage>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<egInkCov:pct>.1100740418</egInkCov:pct>
<egInkCov:mm2>1106.</egInkCov:mm2>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInkCov:pct>1.734313067</egInkCov:pct>
<egInkCov:mm2>17426.</egInkCov:mm2>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInkCov:pct>.07145855515</egInkCov:pct>
<egInkCov:mm2>718.</egInkCov:mm2>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInkCov:pct>.01224150736</egInkCov:pct>
<egInkCov:mm2>123.</egInkCov:mm2>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInkCov:pct>41.64401564</egInkCov:pct>
<egInkCov:mm2>418430.</egInkCov:mm2>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInkCov:pct>0.</egInkCov:pct>
<egInkCov:mm2>0.</egInkCov:mm2>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInkCov:pct>0.</egInkCov:pct>
<egInkCov:mm2>0.</egInkCov:mm2>
</rdf:li>
</rdf:Seq>
</egInkCovL:coverage>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:egBarc="http://ns.esko-graphics.com/barcode/1.0/"
xmlns:x="adobe:ns:meta/"
xmlns:egExtFL2="http://ns.esko-graphics.com/extfileslist/2.0/"
xmlns:egCadReg="http://ns.esko-graphics.com/cadreg/1.0/"
xmlns:egExtFl="http://ns.esko-graphics.com/extfileslist/1.0/"
xmlns:egInkCovL="http://ns.esko-graphics.com/inkcovlist/1.0/"
xmlns:egInkCov="http://ns.esko-graphics.com/inkcov/1.0/"
xmlns:xmpmm="http://ns.adobe.com/xap/1.0/mm/"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
xmlns:egPDFNat="http://ns.esko-graphics.com/pdfnatversion/1.0/"
xmlns:egExtF="http://ns.esko-graphics.com/extfile/1.0/"
xmlns:egCadL="http://ns.esko-graphics.com/cadlist/1.0/"
xmlns:xmpRights="http://ns.adobe.com/xap/1.0/rights/"
xmlns:egPagL="http://ns.esko-graphics.com/pagerangelist/1.0/"
xmlns:egBarcL="http://ns.esko-graphics.com/barcodelist/1.0/"
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/"
xmlns:xmpbj="http://ns.adobe.com/xap/1.0/bj/"
xmlns:egFontL="http://ns.esko-graphics.com/fontlist/1.0/"
xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:egFont="http://ns.esko-graphics.com/fontinfo/1.0/"
xmlns:egPag="http://ns.esko-graphics.com/pagerange/1.1/"
xmlns:egLayL="http://ns.esko-graphics.com/laylist/1.0/"
xmlns:egLay="http://ns.esko-graphics.com/layer/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:stLoc="http://ns.adobe.com/xap/1.0/sType/DataLocation#"
xmlns:xapBJ="http://ns.adobe.com/xap/1.0/bj/"
xmlns:egJob="http://ns.esko-graphics.com/jobinfo/1.0/"
xmlns:jy="http://ns.users.skynet.be/jonas.yde/"
>
<xsl:template match="rdf:RDF">
<html>
<head>
<title>
XMP data voor: <xsl:value-of select="//jy:filename"/>
</title>
<style type="text/css">
body {
font-family:Verdana;
font-size:11pt;
width: 1024px;
padding:0px;
margin:0px;
margin-left:5px;
border:none;
}
h1 {
font-size:20pt;
display:inline;
padding: 0px;
margin: 0px;
margin-bottom: 5px;
}
h3 {
font-size:14pt;
padding-top:7px;
padding-bottom:7px;
padding-left:7px;
color: white;
}
h5 {
font-size:14pt;
margin-top:15px;
margin-bottom:5px;
}
a {
color:black;
text-decoration:none;
}
th {
background-color:rgb(167,186,31);
color: white;
padding: 3px;
}
.kleurvak {
position: relative;
top:0px;
left:0px;
height: 15px;
width: 15px;
border: 1px solid black;
margin:2px;
}
.tsstitelachtergrond{
background-color:rgb(49,69,69);
width:100%;
}
.naam{
font-weight:bold;
}
.GroteTabel{
text-align: left;
}
.mediabox{
border: 3px solid black;
}
.trimbox{
border: 3px solid red;
text-color: red;
}
#versie-info {
color:#AAAAAA;
font-size: 8pt;
}
#EAlogo {
width: 140px;
height: 50px;
border: none;
padding: 0px;
position: relative;
top: 15px;
}
#XMPlogo {
width: 90px;
height: 40px;
border: none;
padding: 0px;
position: absolute;
top: 25px;
left: 940;
align: right;
}
/*EskoArtwork-groen:rgb(167,186,31) blauw:rgb(49,69,69)*/
</style>
</head>
<body>
<img id="EAlogo" src="http://img136.imageshack.us/img136/2721/eskoartworklogo.jpg" alt="logo EskoArtwork" />
<h1> <xsl:text> XMP data voor: </xsl:text><xsl:value-of select="//jy:filename"/></h1>
<img id="XMPlogo" src="http://img403.imageshack.us/img403/5980/xmplogo.png" alt="Powered by XMP"/>
<!-- layers, jobs, ink coverage nog doen! -->
<xsl:apply-templates select="rdf:Description[
namespace::*[.='http://ns.esko-graphics.com/inkcovlist/1.0/'] and
namespace::*[.='http://ns.esko-graphics.com/inkcov/1.0/']
]" />
</body>
</html>
</xsl:template>
<!-- esko artwork ink coverage p29 NOG WERK NODIG!-->
<xsl:template match="rdf:Description[
namespace::*[.='http://ns.esko-graphics.com/inkcovlist/1.0/'] and
namespace::*[.='http://ns.esko-graphics.com/inkcov/1.0/']
]">
<div class="tsstitelachtergrond"><h3>Inkt dekking</h3></div>
<xsl:for-each select="egInkCovL:coverage/rdf:Seq/rdf:li">
<xsl:variable name="index" select="number(.)"/>
<xsl:value-of select="//egGr:inks/rdf:Seq/rdf:li[$index]/egInk:name"/>
<xsl:value-of select="format-number(egInkCov:pct,'#0.00')"/> % or
<xsl:value-of select="round(egInkCov:mm2)"/> mm<sup>2</sup><br/>
<br/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: xPath problem
The position() function gives you the index in the current iteration, so define the index variable as
Best Regards,
George
Code: Select all
<xsl:variable name="index" select="position()"/>
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service