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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:47+00:00 2026-05-27T21:46:47+00:00

Using XSLT 1.0, I want to process four node sets, in order, A, B,

  • 0

Using XSLT 1.0, I want to process four node sets, in order, A, B, C, D. But I can’t specify each node set with a single (or at least not manageable) XPath expression.

I’d like to, right up front, sweep through and tag all the nodes I want to be A’s, all the nodes I want to be B’s, etc., and then later be able to select at will all A nodes, all B nodes, etc.

I also might want to add to the list later.

I can’t create attributes in the file I’m processing. (Right?) Variables go out of scope too soon. Maybe something using keys? A key for all A’s, all B’s? But can I add more nodes to a key table once the key has been created?

Or is there a way to save XPaths?

Is there a straightforward way to do this, or must I just create a nasty, awful, error-prone, terrible-to-maintain Xpath expression every time I want to select each of my node sets?

  • 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-27T21:46:48+00:00Added an answer on May 27, 2026 at 9:46 pm

    Solution: Use Global Variables, like this:

    <xsl:variable name="A" select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title" />
    <xsl:variable name="B" select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author" />
    <xsl:variable name="C" select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:sponsor    | 
                                   //tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:funder     | 
                                   //tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:principal  | 
                                   //tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt   |
                                   //tei:teiHeader/tei:fileDesc/tei:editionStmt              |
                                   //tei:teiHeader/tei:fileDesc/tei:extent                   |
                                   //tei:teiHeader/tei:fileDesc/tei:seriesStmt" />
    <xsl:variable name="D" select="//tei:teiHeader/tei:fileDesc/tei:notesStmt/tei:note" />
    

    Then later:

    <xsl:call-template name="writeMetadata">
       <xsl:with-param name="rowitems" select="$A" /> 
    </xsl:call-template>
    <xsl:call-template name="writeMetadata">
       <xsl:with-param name="rowitems" select="$B" /> 
    </xsl:call-template>
    <xsl:call-template name="writeMetadata">
       <xsl:with-param name="rowitems" select="$C" /> 
    </xsl:call-template>
    <xsl:call-template name="writeMetadata">
       <xsl:with-param name="rowitems" select="$D" /> 
    </xsl:call-template>
    

    repeated as often as needed, without needing to repeat the Xpath expressions.

    (Michael, your comment “People often fail to realise that global variable definitions can reference the source document,” posted at dpawson.co.uk, got me looking in the right area.)

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

Sidebar

Related Questions

Using XSLT and XPath 1.0, I have a string I want to escape for
I'm using XSLT 1.0 an want to transform an XML file. It works fine
I want to apply an XSLT Stylesheet to an XML Document using C# and
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
I'd like to output html controls using xslt, but I need to be able
I want to output something similar to the following using XSLT XML: <myroot> <node1>
I have the following line of xml that I'm trying transform using XSLT but
I am creating a table from xml using xslt, and I want every other
I would like to transform an XML document using xslt with a set of
I want to create a ASP.NET user control from an XML using XSLT. Currently

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.