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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:00:26+00:00 2026-05-17T03:00:26+00:00

My source file looks like this: <stuff> <s> <contents> <code>503886</code> <code>602806</code> </contents> … </s>

  • 0

My source file looks like this:

<stuff> 
<s>
    <contents>
      <code>503886</code>
      <code>602806</code>
    </contents>
    ...
</s>
<p>
    <code>344196</code>
    <export>true</export>
    ...
</p>
<!-- more 's' and 'p' tags -->
...
</stuff>

I need to iterate over ‘s’ and choose those – which inside ‘contents’ tag have a ‘code’ that belongs to a ‘p’ that has export=true.

I’ve been trying to solve this for the last couple of hours.
Please share some ideas.

  • 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-17T03:00:26+00:00Added an answer on May 17, 2026 at 3:00 am

    This stylesheet:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:key name="kSByCode" match="s" use="contents/code"/>
        <xsl:template match="text()"/>
        <xsl:template match="p[export='true']">
            <xsl:copy-of select="key('kSByCode',code)"/>
        </xsl:template>
    </xsl:stylesheet>
    

    With this input:

    <stuff>
        <s>
            <contents>
                <code>503886</code>
                <code>602806</code>
            </contents>
        </s>
        <p>
            <code>602806</code>
            <export>true</export>
        </p>
    </stuff>
    

    Output:

    <s>
        <contents>
            <code>503886</code>
            <code>602806</code>
        </contents>
    </s>
    

    Note: Whenever there are cross references, use keys.

    Edit: Missed iterate over s part. Thanks, Dimitre!

    Edit 2: Re reading this answer I saw that it might be confusing. So, for a expression selecting the nodes, use:

    key('kSByCode',/stuff/p[export='true']/code)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My source file looks like this: <x> <names> <name>name1</name> <name>name2</name> </names> <codes> <code>code1</code> <code>code2</code>
consider my source file looks like this. <Content xmlns=uuid:4522eb85-0a47-45f9-8e2b-1x82c78xx920> <first>Hello World.This is Fisrt field</first>
I have an abstract class where source code looks like this: /* * @assert
I have a CMakeLists.txt file that looks like this: add_executable(exec1 exec1.c source1.c source2.c source3.c)
My XML file looks like this: <Configuration> <Parameters> <Component Name=Aas> <Group Name=PrivilegesMapping> <Parameter Name=PrivilegesLoaderInterval>
My project.clj file looks like this (defproject cljs-template 0.1.0-SNAPSHOT :description FIXME: write this! :url
My source and build tree looks like this (see Makefile to put object files
Say I have a text file that looks like this: date 1/1/2010 a,b,c a,b,d
I have a header file that looks like this: #pragma once //C++ Output Streams
Given some source file (or more generic - input stream), I need to find

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.