Thank you! This is very good info. I will print it out and try to hammer it
in.  XSL at fist glance seems so easy, but it can be quite complicated. I
plan t do a more advanced tutorial.  The one I did last time was too easy.

Thank you very much, you really know your stuff!!!

On Wed, Oct 10, 2012 at 2:19 PM, helix84 <[email protected]> wrote:

> Jose, those are very good questions. You may need to read the answer
> more than once before it starts making sense.
>
> On Wed, Oct 10, 2012 at 7:46 PM, Jose Blanco <[email protected]> wrote:
> > Ok, by adding the select tags where you indicate I get what I want.  But
> I
> > don't quite understand why. Why would another match on the same tag be
> > allowed to execute.
>
> First of all, the important units in XSL are templates (not
> stylesheets). A template matches a part of XML tree in the input
> document and produces an arbitrary part of the output document (in our
> case HTML).
>
> You can have one template that matches the parent element, and another
> one that matches its child element. The one matching parent will be
> used, simply because the parser always encounters the parent first in
> the input document.
>
> Two templates can match the same element, but they cannot be defined
> in the same stylesheet.
> Being declared in different stylesheets, their priority is clear based
> on whether import or include is used (see the link I sent you).
> If you want, you can change this default priority using an explicit
> "priority" attribute.
>
> The effect of all that is that there is always just one template
> matching a particular XML tree fragment.
>
> > I don't completely know what this:
> >
> > <xsl:apply-templates />
> >
> > does.  It seems like it says, look for any other matches like the one I
> just
> > trapped and executed. Right?
>
> Yes, this can be a tough one to understand when you see it for the first
> time.
> Example:
>
> Input XML:
> <?xml version="1.0" encoding="UTF-8"?>
> <parent>
>   <child/>
> <parent>
>
>
> XSLT:
> <xsl:template name="match_parent" match="parent">
>   Transforming parent.
> </xsl:template>
>
> <xsl:template name="match_child" match="child">
>   Transforming child.
> </xsl:template>
>
>
> Output:
> <?xml version="1.0"?>
>   Transforming parent.
>
>
> If you change the match_parent template like this:
> <xsl:template name="match_parent" match="parent">
>   Transforming parent.
>   <xsl:apply-templates/>
> </xsl:template>
>
>
> You'll get this output:
> <?xml version="1.0"?>
>   Transforming parent.
>   Transforming child.
>
>
> Does that make the basics clear? In your case, apply-templates
> triggers processing templates on children of the "field" input element
> and one of these templates generates the "select" output element.
>
> > Also, I added the template you gave me in just an arbitrary xsl file, so
> why
> > is it that that the location of the widget in the html does not change. I
> > have a hard time understanding how the location of the things that
> appear on
> > the html page are associated the location of the xsl.  If I move things
> > around in item-view.xsl, things will move around on the html page, but
> this
> > is not always the case.
>
> Like I said, it doesn't matter at all which stylesheet you put it in.
> The organization into files doesn't matter to the XSLT processor at
> all (unless there are two templates matching exactly the same thing,
> then only one will be used, see include vs. import), it's just for the
> programmer to group things like he wants. Think of it like .c files in
> pure C (templates are like functions, stylesheets are like .c
> modules). When you're looking for a template, don't look into specific
> files like item-view.xsl. Always grep for what the template is
> supposed to match or what it outputs.
>
> Does that make it a little bit clearer? Did I forget to explain something?
>
> Regards,
> ~~helix84
>
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech

Reply via email to