p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Urgent ::Reading two xml files subcontent and adding that to third xml file (http://p2p.wrox.com/showthread.php?t=75533)

archleader August 3rd, 2009 09:26 AM

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.

bonekrusher August 3rd, 2009 12:21 PM

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.

archleader August 3rd, 2009 11:36 PM

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,

Martin Honnen August 4th, 2009 08:09 AM

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.

archleader August 4th, 2009 08:16 AM

I am so sorry Martin it is <section> </section>.

Martin Honnen August 4th, 2009 09:19 AM

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.

archleader August 18th, 2009 03:11 AM

Thanks a ton Martin.

[:)]


All times are GMT -4. The time now is 02:41 PM.

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