Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:15:28+00:00 2026-05-24T20:15:28+00:00

I am parsing itunes library XML file using xslt grammar. Here’s sample code void

  • 0

I am parsing itunes library XML file using xslt grammar.

Here’s sample code

 void ITunesMlibParser::createXslForPlistItems(QString &out, int playlistID)
     {

           std::stringstream ss;
         ss <<  "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
         ss <<  "<xsl:stylesheet version=\"2.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:fn=\"fn\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">";
         ss <<  "<xsl:output method=\"text\" />";

         ss <<  "<xsl:template match=\"/\">";
        // ss << "<xsl:variable name=\"myplaylist\" select=\"'6711'\"/>";


         ss <<  "<xsl:variable name=\"myplaylist\" select=\"'"<< playlistID <<"'\">" ;

         ss <<  "<xsl:variable name=\"playlist_tracks\" select=\"/plist/dict/array/dict[integer[preceding-sibling::key[1]='Playlist ID']=$myplaylist]/array/dict/integer[preceding-sibling::key[1]='Track ID']\" />";
         ss <<  "<xsl:variable name=\"tracks\" select=\"/plist/dict/dict/dict[integer[preceding-sibling::key[1]='Track ID']=$playlist_tracks]\" />";

         ss <<  "<xsl:for-each select=\"$tracks\">";
         ss <<  "<xsl:value-of select=\"integer[preceding-sibling::key[1]='Track ID']\"/>";
         ss <<  "<xsl:text>,</xsl:text>";
         ss <<  "<xsl:value-of select=\"string[preceding-sibling::key[1]='Name']\"/>";
         ss <<  "<xsl:text>,</xsl:text>";
         ss <<  "<xsl:value-of select=\"integer[preceding-sibling::key[1]='Total Time']\"/>";
         ss <<  "<xsl:text>,</xsl:text>";
         ss <<  "<xsl:value-of select=\"string[preceding-sibling::key[1]='Kind']\"/>";
         ss <<  "<xsl:text>,</xsl:text>";
         ss <<  "<xsl:value-of select=\"string[preceding-sibling::key[1]='Location']\"/>";
         ss <<  "<xsl:text>&#xa;</xsl:text>";
         ss <<  "</xsl:for-each>";
         ss <<  "</xsl:template>";
         ss <<  "</xsl:stylesheet>";
         ss <<  "";

         out = QString::fromStdString(ss.str());         
         return;

 }

Consider below two lines:

 // ss << "<xsl:variable name=\"myplaylist\" select=\"'6711'\"/>";
    ss <<  "<xsl:variable name=\"myplaylist\" select=\"'"<< playlistID <<"'\">" ;

If I hard code Integer value of Playlist = 6711, The parser works. But if I programatically pass an integer value, It gives below error.

Error XTSE0620 line 11, column 190: When attribute select is present on variable, a sequence constructor cannot be used.

// My comment --> line 11 is below or I am not sure if this is guilty line as it works with hard coded value.

<xsl:variable name="playlist_tracks" select="/plist/dict/array/dict[integer[preceding-sibling::key[1]='Playlist ID']=$myplaylist]/array/dict/integer[preceding-sibling::key[1]='Track ID']" />

I am stuck here, and badly need some input from XSLT experts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:15:29+00:00Added an answer on May 24, 2026 at 8:15 pm

    I think you simply need to ensure that any xsl:variable element that has a select attribute has no content so make sure you either have e.g. <xsl:variable name="var-name" select="2"/> or <xsl:variable name="var-name" select="2"></xsl:variable>.
    So with your C++ you probably want e.g. ss << "<xsl:variable name=\"myplaylist\" select=\"'"<< playlistID <<"'\"/>" ; though I am not really trained to read and write C++.

    I also wonder why with your XSLT/XPath you are trying to quote the integer values as that way you get strings in XPath while XPath also has numbers. So depending on your needs you might want to drop the single quotes: ss << "<xsl:variable name=\"myplaylist\" select=\""<< playlistID <<"\"/>" ;.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing this xml file here: http://itunes.apple.com/us/rss/toptvepisodes/limit=10/xml . I am getting the preview
Parsing an XML file using the Java DOM parser results in: [Fatal Error] os__flag_8c.xml:103:135:
For parsing an invalid XML file, having either unencoded, illegal characters (ampersands in my
I'm trying to read the iTunes XML file with PHP. I want to extract
I followed a quick tutorial on parsing an XML file, this what i have.
I am trying to parse an itunes affiliate xml link purely for practise, using
In this question (http://stackoverflow.com/questions/1267474/itunes-xml-parsing-in-cocoa), Sreelal asks how to improve performance of loading/parsing a large
For parsing an xml response using TagSoup I am extending the DefaultHandler, now I
Im parsing xml using php and one of my variables receive a long decimal
I`m parsing a Google Maps RSS with javascript and using the following code to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.