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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:08:42+00:00 2026-05-20T01:08:42+00:00

Normally, the XSLT should work on an original XML file and being provided with

  • 0

Normally, the XSLT should work on an original XML file and being provided with a stylesheet.

But currently my task is, my last node in my final XML file should be a number that count certain types of nodes in my RESULTING xml file (not the original one).

So for example, my initial XML is empty, and in my style sheet, I’ve grabbed data from some other places and inserted them into this empty XML to create certain nodes like this:

<Plant>
 <Flower>
   <Flower1>..</Flower1>
   <Flower2>..</Flower2>
 </Flower>

 <Tree>
   <Tree1>...</Tree1>
   <Tree2>...</Tree2>
 </Tree>

  ....

 <Counter>? </Counter>
</Plant>

My question here is this Counter node, it should be a number that indicates how many children nodes of Plant has been created after the transformation. So I would assume a 2-step process could be effective: The first step is to do an intermediate XSLT that grabs all the “Plant” data and filled in the empty initial XML file; Then the second step is to a simple XPath count on this XML file and append another node “Counter” to contain this number. But I am not exactly sure how to do chain these two XSLTs into a single XSLT( since a one-click transform is required), like how to represent the intermediate XML files and how to command the IDE( XMLSpy in my case) to do a further XSLT.

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-05-20T01:08:43+00:00Added an answer on May 20, 2026 at 1:08 am

    Here is a general way to process the result of a transformation, including counting its nodes:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common"
     >
     <xsl:output method="text"/>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="/">
      <xsl:variable name="vrtfPass1">
       <top>
        <xsl:apply-templates select="*"/>
        <xsl:apply-templates select="*"/>
       </top>
      </xsl:variable>
    
      <xsl:variable name="vPass2" select="ext:node-set($vrtfPass1)"/>
    
      <xsl:value-of select="count($vPass2/*/*/*)"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the following XML document:

    <nums>
     <num>1</num>
     <num>2</num>
     <num>3</num>
     <num>4</num>
     <num>5</num>
    </nums>
    

    the correct result is produced:

    10
    

    In XSLT 1.0 (only) the use of the xxx:node-set() extension function is generally required in multi-pass processing. THere is no such requirement in XSLT 2.0, which eliminated the infamous RTF “datatype”.

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

Sidebar

Related Questions

Normally i am using getString(R.string.) to query strings in xml file. Is there any
Normally this would be something like: glutAddMenuEntry(-, <opid>); But it doesn't work. After looking
I want to attach an xslt stylesheet to an XML document that I build
Normally, when I want to allow a user to download a file without revealing
Normally, when using the XMLSerializer to automagically serialize an ISerializable object, a .dll file
I have a maven project that loads an xslt file and executes the transformation
Normally, i should see my provisioning profile in the list here: Why i am
Normally I switch over to the Nerdtree file buffer by hitting Ctrl+H twice to
Normally I would refrain from asking vague questions but in this case I cannot
I am using XmlDocument and XmlNode to manipulate a xml file. Say I want

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.