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 285273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:31:53+00:00 2026-05-12T05:31:53+00:00

The following works for me: <xsl:variable name=core select=document(‘CoreMain_v1.4.0.xsd’) /> <xsl:variable name=AcRec select=document(‘AcademicRecord_v1.3.0.xsd’) /> <xsl:template

  • 0

The following works for me:

<xsl:variable name="core" select="document('CoreMain_v1.4.0.xsd')" />
<xsl:variable name="AcRec" select="document('AcademicRecord_v1.3.0.xsd')" />

<xsl:template match="xs:element">       
  <xsl:variable name="prefix" select="substring-before(@type, ':')" />
  <xsl:variable name="name" select="substring-after(@type, ':')" />

  <xsl:choose>
    <xsl:when test="$prefix = 'AcRec'">             
      <xsl:apply-templates select="$AcRec//*[@name=$name]">
        <xsl:with-param name="prefix" select="$prefix" />
      </xsl:apply-templates>                
    </xsl:when>
    <xsl:when test="$prefix = 'core'">              
      <xsl:apply-templates select="$core//*[@name=$name]">
        <xsl:with-param name="prefix" select="$prefix" />
      </xsl:apply-templates>                
    </xsl:when>             
  </xsl:choose>
</xsl:template>

But I use the same logic to handle the lookup of elements in the current or other documents based on the prefix, matching the node name in numerous places within the stylesheet. So, after changing the stylesheet version to 2.0, I tried:

<xsl:template match="xs:element">
  <xsl:value-of select="my:lookup(@type)" />
</xsl:template>

<xsl:function name="my:lookup">
  <xsl:param name="attribute" />

  <!-- parse the attribute for the prefix & name values -->
  <xsl:variable name="prefix" select="substring-before($attribute, ':')" />
  <xsl:variable name="name" select="substring-after($attribute, ':')" />

  <!-- Switch statement based on the prefix value -->
  <xsl:choose>
    <xsl:when test="$prefix = 'AcRec'">             
      <xsl:apply-templates select="$AcRec//*[@name=$name]">
        <xsl:with-param name="prefix" select="$prefix" />
      </xsl:apply-templates>                
    </xsl:when>
    <xsl:when test="$prefix = 'core'">              
      <xsl:apply-templates select="$core//*[@name=$name]">
        <xsl:with-param name="prefix" select="$prefix" />
      </xsl:apply-templates>                
    </xsl:when>             
  </xsl:choose> 
</xsl:function>

In my reading, I have only found examples of functions that return text – none call templates. I have the impression that an xsl:function should always return text/output…

After more investigation, it is entering the my:lookup function and the variables (prefix & name) are getting populated. So it does enter the xsl:choose statement, and the hits the appropriate when test. The issue appears to be with the apply-templates – value-of is displaying the child values; copy-of does as well, which I think is odd (shouldn’t the output include the xml element declarations?). Why would there be a difference if code that works in a template declaration is moved to an xsl:function?

  • 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-12T05:31:53+00:00Added an answer on May 12, 2026 at 5:31 am

    It’s been a while since I did any serious XSLT, but IIRC your problem is not in the function, but in your template:

    <xsl:template match="xs:element">
      <xsl:value-of select="my:lookup(@type)" />
    </xsl:template>
    

    The value-of statement won’t inline the result tree returned by your function. Instead, it’s going to try and reduce that result tree down into some kind of string, and inline that instead. This is why you’re seeing the child values and not the elements themselves.

    To inline the result tree returned by your function, you’ll need to use some templates to copy the result tree into place.

    So, your main template will need to change to this:

    <xsl:template match="xs:element">
      <xsl:apply-templates select="my:lookup(@type)" />
    </xsl:template>
    

    and you’ll need some templates to do the recursive call. A quick google found a good discussion of the identity template that should do what you need.

    (Please forgive any syntax errors, as I said, it’s been a while …)

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

Sidebar

Related Questions

I had the following definition for a variable <xsl:variable name=DataType select=@DataType/> Which works just
I have the following XSLT variable: <xsl:variable name=superid select=/contentdata/id/> Furthermore, I have a node
I have the following snippet of XSL: <xsl:for-each select=item> <xsl:variable name=hhref select=link /> <xsl:variable
<xsl:template match=element[child]> The above works. What is the real syntax for the following pseudo-syntax?
I have the following in my xslt file: <xsl:param name=predicate select=//Event /> <xsl:apply-templates select=$predicate
Following XLST code works fine :- <?xml version=1.0?> <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform version=1.0> <xsl:template match=/> <xsl:for-each
Can somebody explain to me why the following works: template<class T> class MyTemplateClass {
When I have the following (default) declaration in my XSL file, everything works fine.
Following works fine in shell: >>> from django.contrib.auth.models import User >>> user=User.objects.get(pk=1) >>> user.first_name
The following works in current Firefox (PDF loads), but not in current IE (page

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.