CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Posts
    2

    Unhappy How can I join (merge) two node-sets into another node-set?

    I've read in (via document()) two node-sets and put them in variables. Now I'd like to combine them into a single node-set (not as text or a result-tree-fragment) variable by linking them together via a key field. There's got to be an easy way to do this. My data looks something like this:

    $names:
    Code:
    <row><col type="id">a</col><col type="name">First name</col></row>
    <row><col type="id">b</col><col type="name">Second name</col></row>
    <row><col type="id">c</col><col type="name">Third name</col></row>
    <row><col type="id">d</col><col type="name">Forth name</col></row>
    $numbers:
    Code:
    <row><col type="id">c</col><col type="qty">33</col></row>
    <row><col type="id">a</col><col type="qty">11</col></row>
    What I'd like to get back (in some form) is:
    $together:
    Code:
    <row><col type="id">c</col><col type="name">Third name</col><col type="qty">33</col></row>
    <row><col type="id">a</col><col type="name">First name</col><col type="qty">11</col></row>
    Now I think I could come up with a whole stylesheet to do this job for direct translation purposes, but I'm actually needing to imbed this in a large HTML-output stylesheet (that's running off a completely different XML file) and use the resulting node-set in a for-each loop. How might I do this in some easy fashion?

    (I'm running IE7 under XP, but it'd be nice if it were somewhat portable. All the XML/XSL files are local and the machine may not be web-connected when running, in case that matters for external namespaces or the like.)

  2. #2
    Join Date
    Apr 2008
    Posts
    12

    Re: How can I join (merge) two node-sets into another node-set?

    You will have to use msxml:node-set to use the resulting node-set in a for-each loop.

  3. #3
    Join Date
    Apr 2008
    Posts
    2

    Re: How can I join (merge) two node-sets into another node-set?

    Thanks. I was hoping for an alternative that didn't require msxml:node-set because I'm not sure I can have it available everywhere I need to use this. Maybe I'll be able to come up with alternative somehow, probably with a triply-nested for-each, or something like that.

  4. #4
    Join Date
    Apr 2008
    Posts
    12

    Re: How can I join (merge) two node-sets into another node-set?

    You can also use exslt:node-set if not with a Microsoft XML parser.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured