xsl-list
[Top] [All Lists]

How adress what might be attribute or element?

2006-01-18 12:36:27
Hi all,

I haven't found a solution for two of my current problems in the archive. So I 
hope someone out there can help me, or show me where I got off on the wrong 
track. I'll do this in two different mails, as the topics are quite different.
I'm on the digest version of the list, so I can only answer question tomorrow.

Here comes the first Problem:

I'm working with an XMP-Dump file and want to extract certain data. 
Unfortunately, I do not know if the data comes in an element or an attribute, 
as both versions are legal with XMP.

So I may have

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1.1-111">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
      <rdf:Description rdf:about=""
            xmlns:tiff="http://ns.adobe.com/tiff/1.0/";>
        <tiff:Orientation>1</tiff:Orientation>
         <tiff:XResolution>720000/10000</tiff:XResolution>
         
         ....
         </rdf:Description>
      <rdf:Description rdf:about=""
            xmlns:xap="http://ns.adobe.com/xap/1.0/";>
         <xap:CreateDate>1999-12-12T14:33:22+01:00</xap:CreateDate>
...

Or
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1.1-111">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
      <rdf:Description rdf:about=""
            xmlns:tiff="http://ns.adobe.com/tiff/1.0/";         
          tiff:Orientation="1"
         tiff:XResolution="720000/10000" 
         tiff:ImageWidth="12367"
         tiff:ImageLength="3346" />
         ....
         
      <rdf:Description rdf:about=""
      xmlns:xap="http://ns.adobe.com/xap/1.0/";>
      xap:CreateDate="1999-12-12T14:33:22+01:00" />




So at the moment I do this:

    <xsl:template name="Steckbriefkopf">
               <table>
            <tr>
                <td>Image:</td>
                <td>
                     <xsl:value-of 
select="/x:xmpmeta/rdf:RDF/rdf:Description/@tiff:ImageWidth" /> 
                    <xsl:value-of 
select="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:ImageWidth" />
                    <xsl:text> x </xsl:text>
                    
                    <xsl:value-of 
select="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:ImageLength" />
                       <xsl:value-of 
select="/x:xmpmeta/rdf:RDF/rdf:Description/@tiff:ImageLength" />  
                    
                    <xsl:text> Pixel</xsl:text>
                    
                </td>
                <td>
                            <xsl:variable name="xresolution">
                                <xsl:value-of 
select="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:XResolution" />
                            </xsl:variable>
                            <xsl:variable name="yresolution">
                                <xsl:value-of 
select="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:YResolution" />
                            </xsl:variable>

                    
                    <xsl:choose>
                        <xsl:when test="$xresolution = $yresolution">
                            <xsl:value-of select="$yresolution"/>
                            
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$xresolution" />
                            <xsl:text> x </xsl:text>
                            <xsl:value-of select="$yresolution" />
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when 
test="/x:xmpmeta/rdf:RDF/rdf:Description/@tiff:ResolutionUnit !=3">
                            <xsl:text> dpi</xsl:text>
                        </xsl:when>
                        <xsl:when 
test="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:ResolutionUnit !=3">
                            <xsl:text> dpi</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text> Pixel/cm</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
            </tr>
            
            
When it comes to the resolution, I'm a bit stuck.

Can I put two <xsl:value-of select /> statements in each variable? 



And besides, all this 
<xsl:value-of select="@namspace:bla />
<xsl:value-of select="namespace:bla />

makes the code rather long and slows down the processing.Is there a better way 
to do this?

Would 
<xsl:value-of select="@namespace:bla | namespace:bla" be any better where 
performance is concerned?

Regards from a snowy Berlin
CJ 



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>