Sunday 15 July 2012

text - xslt split mp3 tag into artist and title -


Many times, mp3 tags are in the form of "artist - title", but headings are stored in the field.

I want to split prices into Artists + Title fields.

Examples of before / after partitions:

  & lt; Title & gt; Artist - Title & lt; / Title & gt; & Lt; Title & gt; - Title & lt; / Title & gt; & Lt; Title & gt; Artist - & lt; / Title & gt; & Lt; Title & gt; A title & lt; / Title & gt;   

after:

    

I have not done a lot in programming in XSLT, so I do not know if the phrase used in regular languages ​​would fit, and if so, then XSLT language element is the most Good will be used.

In this way, I normally take this approach:

  1. Calculate the first position
  2. If it is not found, Return the code> heading element and an empty artist
  3. if this condition is found at 0, then it will be labeled as title element, then tag as the new title element and an empty artist element .
  4. If this condition is found on the length-3, then remove it from the title element, then the rest of the title tag as the new artist Return element and an empty title
  5. it is found to be larger than 0, in the form of a artist element Everything copies, then return everything to element

    except for talk about 'deletion' and so on, which is not applicable They are (XSLT programs read inputs and produce production; they do not change their input), your description is a very good match. Here (not tested) how to write it (except that I do not give it a very heavy comment):

       & Lt; / XSL: element & gt; & Lt ;! - * Now emits a title with the rest of the value * - & gt; & Lt; Xsl: element name = "title" & gt; & Lt; XSL: Select & gt; & Lt; Xsl: when test = "is included (., '-')" & gt; & Lt; Xsl: Select the value = "normal-space (overhead-later (., '-'))" /> & Lt; / XSL: When & gt; & Lt; XSL: otherwise & gt; & Lt; XSL: implemented-templates / & gt; & Lt; / XSL: otherwise & gt; & Lt; / XSL: Select & gt; & Lt; / XSL: element & gt; & Lt; / XSL: Templates & gt;    

No comments:

Post a Comment