[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How adress what might be attribute or element?

Subject: Re: How adress what might be attribute or element?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 18 Jan 2006 13:04:29 GMT
x xmpmeta
> Can I put two <xsl:value-of select /> statements in each variable? 
You can put any number of xsl constructs there, but in fact you don't
really want any xsl:value-of here.

         <xsl:variable name="xresolution">
                                <xsl:value-of select="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:XResolution" />
                            </xsl:variable>

don't use xsl:variable with content unless you need to, it creates a
result tree fragment (or temporary tree in xslt2) when you just need to
select the element directly
<xsl:variable name="xresolution"
select="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:XResolution">

You could write

                     <xsl:value-of select="/x:xmpmeta/rdf:RDF/rdf:Description/@tiff:ImageWidth" /> 
                    <xsl:value-of select="/x:xmpmeta/rdf:RDF/rdf:Description/tiff:ImageWidth" />

as
    <xsl:value-of
    select="/x:xmpmeta/rdf:RDF/rdf:Description/@tiff:ImageWidth
   |
/x:xmpmeta/rdf:RDF/rdf:Description/tiff:ImageWidth
" /> 

But that doesn't really look any nicer. if you are using XSLT2 you could
write


  <xsl:value-of
    select="/x:xmpmeta/rdf:RDF/rdf:Description/(tiff:ImageWidth|@tiff:ImageWidth)
" /> 

Or In XSLT1 I'd probably change the current node, and write

<xsl:for-each select="/x:xmpmeta/rdf:RDF/rdf:Description">
 <xsl:value-of select="tiff:ImageWidth|@tiff:ImageWidth"/>
</xsl:for-each>

(But if you use for-each  in the cases where you use variables, you would have
to use the content of the variable rather than a select attribute.)

If I was doing this in xslt2 I'd probably write a function

<xsl:function name="f:property" as="xs:string">
 <xsl:param name="x" as="xs:string"/>
 <xsl:sequence select="string((@*|*)[local-name()=$x][1])"/>
</xsl:function>

used as
<xsl:value-of
    select="/x:xmpmeta/rdf:RDF/rdf:Description/f:property('ImageWidth')"/>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.