Attribute selection

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Attribute selection

Joseph L. Casale

When using a pattern of template and selections similar to:

 

<xsl:template match="/">

   <xsl:apply-templates select="…" mode="doc"/>

</xsl:template>

 

<xsl:template match="…" mode="doc">

   <xsl:result-document href="{.}.cs">

     <!-- now produce content of file here -->

   </xsl:result-document>

</xsl:template>

 

The “apply-templates” selection finds elements with multiple

attributes present and I would like to use those in the selected

template.

 

I have simply passed in parameters to the template however

is there a simpler means to gain access to all the attributes within

an element matched?

Thanks,
jlc


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Attribute selection

Martin Honnen-2
Joseph L. Casale wrote:

> I have simply passed in parameters to the template however
>
> is there a simpler means to gain access to all the attributes within
>
> an element matched?

Within of <xsl:template match="foo">...</xsl:template> the matched 'foo'
element node is the context node and of course you can then access all
its attributes with @* or a specific attribute with @bar.

Note that general XSLT questions not specific to Saxon should go on the
Mulberry XSL mailing list or on StackOverflow.

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Attribute selection

Dimitre Novatchev
In reply to this post by Joseph L. Casale
On Sun, Jan 25, 2015 at 9:44 AM, Joseph L. Casale
<[hidden email]> wrote:
> is there a simpler means to gain access to all the attributes within
>
> an element matched?



Use:

  @*

For example:

  <xsl:apply-templates select="@*/>

or (not so good):

  <xsl:for-each select="@*">

       <!-- Necessary processing here -->

  </xsl:for-each>


You may find useful some basic learning resources about XML and XPath,
such as the books by Michael Kay, or some Pluralsight video courses.



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Attribute selection

Joseph L. Casale
In reply to this post by Martin Honnen-2
Martin Honnen  wrote:
> Within of <xsl:template match="foo">...</xsl:template> the matched 'foo'
> element node is the context node and of course you can then access all
> its attributes with @* or a specific attribute with @bar.
>
> Note that general XSLT questions not specific to Saxon should go on the
> Mulberry XSL mailing list or on StackOverflow.

Think you Martin and Dimitre,
Got what I needed and joined the other list as well.

Thanks,
jlc

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help