Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 3rd, 2009, 09:26 AM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Urgent ::Reading two xml files subcontent and adding that to third xml file

hi all,
My requirement is like i have total three xml files.each file contain some specification and a tag <select></select>.
I have to read two files <select> tag and add that into first xml file.

i request you to please help me.
  #2 (permalink)  
Old August 3rd, 2009, 12:21 PM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Welcome to the forum. Now, with that out of the way, you might want to re ask your question with more detail. Your question is very vague. You haven't shown any code or what part of the code you are having a problem with.
  #3 (permalink)  
Old August 3rd, 2009, 11:36 PM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ,
I will describe it to you properly.
I have Three XML files:
Simple.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ip-tests SYSTEM "IPTestingTestImport.dtd">
<ip-tests locale-id="1033">
   <test>
      <test-setup>
         <test-title>Sample</test-title>
         <cost/>
         <serial-number>Infosys</serial-number>
         <version>1.0</version>
         <description>Sample</description>
         <instructions>Instructions will go here</instructions>
         <test-confidentiality>Confidentiality agreement </test-confidentiality>
         <item-delivery-order-type type="3"/>
         <is-navigation-allowed type="Y"/>
         <section-header-display-option type="1"/>
         <beta-item-feedback enable="N"/>
         <authoring-public-or-restricted type="restricted"/>
         <is-proctor-required value="Y"/>
         <test-start-time year="2008" month="01" day="01" hour="00" minute="00" second="00"/>
         <test-end-time year="2008" month="12" day="31" hour="23" minute="59" second="59"/>
         <is-public value="Y"/>
         <max-attempts-qty attempts="3" timeframe="per-year"/>
         <time-limit hour="01" minute="00" show-timer="Y"/>
         <score-not-map type="2"/>
         <passing-score-percent value="0"/>
         <immed-feedback-type id="1"/>
         <final-feedback-type id="1"/>
         <section-score-package type="8"/>
         <is-candidate-emailed value="Y"/>
         <screen-size type="3"/>
      </test-setup>
      <section>
         <section-name>Sample</section-name>
         <is-required-section-pass value="N"/>
         <cut-score-percent>0</cut-score-percent>
         <optional-items-delivered>3</optional-items-delivered>

         <item type="2">
            <short-description>2978722793224950</short-description>
            <item-serial-number>2978722793224950</item-serial-number>
            <item-status value="normal"/>
            <is-mandatory value="N"/>
            <label-type value="2"/>
            <points-possible value="1"/>
            <display-properties type="2"/>
            <display-position value="2"/>
            <raw-html value="0"/>
            <stem>&lt;font face="Arial" size="3"&gt;
Which are the cities in which Infosys works
</stem>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;MonteCarlo</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="1"/>
               <is-correct value="Y"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Fremont</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Hawaii</distractor-text>
            </distractor>
         </item>

         <item type="2">
            <short-description>0909444436900545</short-description>
            <item-serial-number>0909444436900545</item-serial-number>
            <item-status value="normal"/>
            <is-mandatory value="N"/>
            <label-type value="2"/>
            <points-possible value="1"/>
            <display-properties type="2"/>
            <display-position value="2"/>
            <raw-html value="0"/>
            <stem>&lt;font face="Arial" size="3"&gt;
Corporate office of Infosys is located in ___________ DC?
</stem>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Mysore</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="1"/>
               <is-correct value="Y"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Bangalore</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Pune</distractor-text>
            </distractor>
         </item>

         <item type="2">
            <short-description>8659275491970383</short-description>
            <item-serial-number>8659275491970383</item-serial-number>
            <item-status value="normal"/>
            <is-mandatory value="N"/>
            <label-type value="2"/>
            <points-possible value="1"/>
            <display-properties type="2"/>
            <display-position value="2"/>
            <raw-html value="0"/>
            <stem>&lt;font face="Arial" size="3"&gt;
What are the domains in which Infosys works?
</stem>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Disease diagonsis</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="1"/>
               <is-correct value="Y"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Banking</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;Genomics</distractor-text>
            </distractor>
         </item>

      </section>
   </test>
</ip-tests>
medium.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ip-tests SYSTEM "IPTestingTestImport.dtd">
<ip-tests locale-id="1033">
   <test>
      <test-setup>
         <test-title>Sample</test-title>
         <cost/>
         <serial-number>Infosys</serial-number>
         <version>1.0</version>
         <description>Sample</description>
         <instructions>Instructions will go here</instructions>
         <test-confidentiality>Confidentiality agreement </test-confidentiality>
         <item-delivery-order-type type="3"/>
         <is-navigation-allowed type="Y"/>
         <section-header-display-option type="1"/>
         <beta-item-feedback enable="N"/>
         <authoring-public-or-restricted type="restricted"/>
         <is-proctor-required value="Y"/>
         <test-start-time year="2008" month="01" day="01" hour="00" minute="00" second="00"/>
         <test-end-time year="2008" month="12" day="31" hour="23" minute="59" second="59"/>
         <is-public value="Y"/>
         <max-attempts-qty attempts="3" timeframe="per-year"/>
         <time-limit hour="01" minute="00" show-timer="Y"/>
         <score-not-map type="2"/>
         <passing-score-percent value="0"/>
         <immed-feedback-type id="1"/>
         <final-feedback-type id="1"/>
         <section-score-package type="8"/>
         <is-candidate-emailed value="Y"/>
         <screen-size type="3"/>
      </test-setup>
      <section>
         <section-name>Sample</section-name>
         <is-required-section-pass value="N"/>
         <cut-score-percent>0</cut-score-percent>
         <optional-items-delivered>2</optional-items-delivered>

         <item type="2">
            <short-description>4538299758315200</short-description>
            <item-serial-number>4538299758315200</item-serial-number>
            <item-status value="normal"/>
            <is-mandatory value="N"/>
            <label-type value="2"/>
            <points-possible value="1"/>
            <display-properties type="2"/>
            <display-position value="2"/>
            <raw-html value="0"/>
            <stem>&lt;font face="Arial" size="3"&gt;
Infosys is stands at CMM level?
</stem>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;10</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="1"/>
               <is-correct value="Y"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;5</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;4</distractor-text>
            </distractor>
         </item>

         <item type="2">
            <short-description>6321098294899716</short-description>
            <item-serial-number>6321098294899716</item-serial-number>
            <item-status value="normal"/>
            <is-mandatory value="N"/>
            <label-type value="2"/>
            <points-possible value="1"/>
            <display-properties type="2"/>
            <display-position value="2"/>
            <raw-html value="0"/>
            <stem>&lt;font face="Arial" size="3"&gt;
Infosys was started in 1981 in pune
</stem>
            <distractor>
               <points-possible value="1"/>
               <is-correct value="Y"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;TRUE</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;FALSE</distractor-text>
            </distractor>
         </item>

      </section>
   </test>
</ip-tests>
Complex.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ip-tests SYSTEM "IPTestingTestImport.dtd">
<ip-tests locale-id="1033">
   <test>
      <test-setup>
         <test-title>Sample</test-title>
         <cost/>
         <serial-number>Infosys</serial-number>
         <version>1.0</version>
         <description>Sample</description>
         <instructions>Instructions will go here</instructions>
         <test-confidentiality>Confidentiality agreement </test-confidentiality>
         <item-delivery-order-type type="3"/>
         <is-navigation-allowed type="Y"/>
         <section-header-display-option type="1"/>
         <beta-item-feedback enable="N"/>
         <authoring-public-or-restricted type="restricted"/>
         <is-proctor-required value="Y"/>
         <test-start-time year="2008" month="01" day="01" hour="00" minute="00" second="00"/>
         <test-end-time year="2008" month="12" day="31" hour="23" minute="59" second="59"/>
         <is-public value="Y"/>
         <max-attempts-qty attempts="3" timeframe="per-year"/>
         <time-limit hour="01" minute="00" show-timer="Y"/>
         <score-not-map type="2"/>
         <passing-score-percent value="0"/>
         <immed-feedback-type id="1"/>
         <final-feedback-type id="1"/>
         <section-score-package type="8"/>
         <is-candidate-emailed value="Y"/>
         <screen-size type="3"/>
      </test-setup>
      <section>
         <section-name>Sample</section-name>
         <is-required-section-pass value="N"/>
         <cut-score-percent>0</cut-score-percent>
         <optional-items-delivered>2</optional-items-delivered>

         <item type="2">
            <short-description>3982789083708366</short-description>
            <item-serial-number>3982789083708366</item-serial-number>
            <item-status value="normal"/>
            <is-mandatory value="N"/>
            <label-type value="2"/>
            <points-possible value="1"/>
            <display-properties type="2"/>
            <display-position value="2"/>
            <raw-html value="0"/>
            <stem>&lt;font face="Arial" size="3"&gt;
Infosys is stands at CMM level?
</stem>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;10</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="1"/>
               <is-correct value="Y"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;5</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;4</distractor-text>
            </distractor>
         </item>

         <item type="2">
            <short-description>6773019533893213</short-description>
            <item-serial-number>6773019533893213</item-serial-number>
            <item-status value="normal"/>
            <is-mandatory value="N"/>
            <label-type value="2"/>
            <points-possible value="1"/>
            <display-properties type="2"/>
            <display-position value="2"/>
            <raw-html value="0"/>
            <stem>&lt;font face="Arial" size="3"&gt;
Infosys was started in 1981 in pune
</stem>
            <distractor>
               <points-possible value="1"/>
               <is-correct value="Y"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;TRUE</distractor-text>
            </distractor>
            <distractor>
               <points-possible value="0"/>
               <is-correct value="N"/>
               <distractor-text>&lt;font face="Arial" size="3"&gt;FALSE</distractor-text>
            </distractor>
         </item>

      </section>
   </test>
</ip-tests>
I have to take out data of only <sequense></sequense> tag with tag from medium.xml and complex.xml and add it to within Simple.xml as a single consolidate file,while keeping rest of the data of Simple.xml file as it is.

Regards,
  #4 (permalink)  
Old August 4th, 2009, 08:09 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I am afraid I don't find any elements named 'sequense' (or 'sequence') in the XML samples you posted so it does not have become clearer what you want to achieve.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
  #5 (permalink)  
Old August 4th, 2009, 08:16 AM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am so sorry Martin it is <section> </section>.
  #6 (permalink)  
Old August 4th, 2009, 09:19 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:template match="@* | node()">
    <xsl:copy>
       <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="test">
     <xsl:copy>
       <xsl:apply-templates select="@* | node()"/>
       <xsl:apply-templates select="document('medium.xml')/ip-tests/test/section"/>
       <xsl:apply-templates select="document('complex.xml')/ip-tests/test/section"/>
     </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
That copies the section elements in medium and complex.xml at the end of the test element in simple.xml.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog

Last edited by Martin Honnen; August 4th, 2009 at 09:24 AM.. Reason: correcting typo
  #7 (permalink)  
Old August 18th, 2009, 03:11 AM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a ton Martin.



Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
reading a XML file connect2sandep XML 1 December 14th, 2006 04:50 AM
reading a XML file connect2sandep General .NET 0 December 13th, 2006 02:10 PM
Problem to create an xml file from two xml files saurabh_inblore XSLT 1 April 12th, 2006 02:58 AM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.