[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] search for aligned elements


Subject: Re: [xsl] search for aligned elements
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 18 Jul 2007 08:36:59 +0200

Hmm, a little misunderstanding perhaps....

XML is used for the data. There are two versions current of XML, which are 1.0 and 1.1. Unless for some corner cases, XML 1.0 is usually enough for your needs.

XPath is a different standard and is often used in conjunction with XSLT. You mention a link to the specs of XPath 1.0. Do you mean you can only use XPath, or can u also use XSLT? If so, what version? There is a huge difference between solutions in XSLT/XPath 1.0 and 2.0. Also, if you can only use XPath and not XSLT, the solution will be quite different.

In you OP you don't specify what "aligning" means to you. Maybe it is easy (i.e., the same start tracks). Probably it is easy in XSLT (because it seems to be about transforming XML to XML and often that is easiest in XSLT), but whether it will be easy or hard and whether you better use 1.0 or 2.0 depends on your problem description, of course.

You talk of adding an element to the tree. That sounds like a copy idiom to me. That's easy (but not necessarily so if it is your first attempt with xslt), something like this:

<xsl:template match="node() | @*">
   <xsl:copy>
       <xsl:apply-templates select="node() | @*" />
   </xsl:copy>
</xsl:template>

<!-- aligned tracks, meaning: following items have equal starts (???) -->
<xsl:template match="track[following-sibling::track[1]/@start = @start]">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
<!-- add extra track -->
<track aligned-index1="{@index}" aligned-index2="{following-sibling::track[1]/@index}" />
</xsl:template>



The above works in both XSLT 1.0 and 2.0. However it is likely that this is not an answer to your (yet) unspecified question ;)


Cheers,
-- Abel Braaksma


Rodrigo Segnini wrote:
Hi Justin,

Thank you for your reply.
I could easily start using anything that you suggest. Or perhaps there
is a better forum for dealing with my question.

I have been traversing the xml document from within Matlab using the
XMLtree toolbox which deals with XML 1.0 files. I can type in directly
xpath strings compliant with:

Grammar for addressing parts of an XML document:
        XML Path Language XPath (http://www.w3.org/TR/xpath)
 Example: /element1//element2[1]/element3[5]/element4

But I thought there might be some advantages in using XML 'native'
methods, outside of Matlab (like Saxon), hence my question.

On 7/18/07, Justin Johansson <procode@xxxxxxxxxx> wrote:
Hi Rodrigo,

>I am interested in finding elements across tracks falling within the
>same range as delimited by the start and end fields. There are various
>rules to determine what means to be within range or not.

There is a big difference in the answer to your question depending on what
XSL/XPath Version you are using.


Quoting from the list guidlines ... since I just joined the list myself and
read them :-)


<guideline>
IN YOUR POSTING ...

Name the XSL processor, processor version, and version of the language you
are using. This information is frequently necessary to diagnose a problem
exactly, and always helps respondents give good advice.
</guideline>



Justin Johansson Freelance XML / XSLT / XQuery Developer Australia

procode(at)tpg(dot)com(dot)au


Current Thread
Keywords