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

  • SEARCH
  • Home
  • 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 8268577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:56:17+00:00 2026-06-08T05:56:17+00:00

my xsl stylesheet just works fine except the thing that i cant use attributes

  • 0

my xsl stylesheet just works fine except the thing that i cant use attributes in my stylesheet. But i really need them to complete my function.

I’m using the xsl in php and when i try to declare an attribute and use , the xsl thinks that $attr is a php variable and the function crashes.

This is my code

<?php
function releaseNotes($source, $type, $order_by, $sort) {

$type = $type ? "[@type='{$type}']" : "";

$xsl = <<<XSL
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="versions" match="issue" use="fix_versions"/>
<xsl:key name="type" match="issue" use="concat(fix_versions, '+', @type)"/>

  <xsl:template match="issues">



      <xsl:for-each select="//issue[generate-id(.)=generate-id(key('versions', fix_versions)[1])]">

        <xsl:sort select="fix_versions" order="descending"/> 

        <div class="release">

            <a href="" class="version"><xsl:value-of select="fix_versions"/></a>




            <xsl:attribute name="version"><xsl:value-of select="fix_versions"/></xsl:attribute>
            <xsl:value-of select="$version"/>
            <xsl:if test="//release[@version = '$version']">
              Yeah
            </xsl:if>



            <div class="version" style="display:none;">

            <xsl:for-each select="key('versions', fix_versions)">

                <xsl:for-each select="key('type', concat(fix_versions, '+', @type))">
                    <div style="border-bottom:1px solid grey;">
                    <a href="" class="title"><xsl:value-of select="title"/></a>
                    <div class="toggle" style="display:none;">
                        <xsl:value-of select="description"/>

                </div>
          </div>                        
            </xsl:for-each>

            </div>
       </div>
      </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>
XSL;

$xmldoc = new DOMDocument('1.0', 'utf-8');
$xmldoc->load($source);
$xsldoc = DOMDocument::loadXML($xsl);

$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsldoc);
return $proc->transformToXML($xmldoc);
}
?>  

No matter where i try to use an attribute – as soon as i want to use it, i get no result of the function anymore? Any idea?

Seems to be useless in this example but i want to check if there is a node “release” with this version number so i need to get the version of the current string as an attribute.

The xml structure is like this

<release version="x.x.x" name="release1"/>
<release version="x.x.x" name="release2"/>
<release version="x.x.x" name="release3"/>
<issues>
  <issue><fix_versions>x.x.x</fix_versions></issue>
  <issue><fix_versions>x.x.x</fix_versions></issue>
  <issue><fix_versions>x.x.x</fix_versions></issue>
</issues>

Only issues of already released versions should be visible. Thats why i have to check for the issue if there is an release with the same version

Everything works fine, even grouping, but the attributes. As i said the function takes $version just as a php variable instead of the name of the aatribute.

Thanks in advance

  • 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-06-08T05:56:19+00:00Added an answer on June 8, 2026 at 5:56 am

    Your question is a little confusing, but if you mean the problem is that:

    $type = $type ? "[@type='{$type}']" : "";
    

    gets translated as $type is a variable and gets expanded, if you put a \ in front of the variable, it will work, or even in single quotes:

    $type = $type ? "[@type='{\$type}']" : "";
    or 
    $type = $type ? "[@type='".'{$type}'."']" : "";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XSL stylesheet (A) that imports another one (B). A overrides a
I'm working with an XSL stylesheet, and I'm trying to use the method shown
I have got an XSLT that looks like this: <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output method=xml
Simple question: Why is a PHP function called from an XSL Stylesheet just returning
I've got an XML data file that I'm applying an XSL stylesheet to, using
I'm trying to use a .xsl file so that it will return a HTML
I have stylesheets and schemas that uses namespaces e.g. <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
I just created a XSL file that sorts my XML. Now I want to
I have a huge xsl file but the section where i use tokenize to
I am debugging the xsl stylesheet of someone else and I noticed a lot

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.