Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 20th, 2007, 09:34 AM
Registered User
 
Join Date: Dec 2007
Location: hyderabad, AP, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to insert one xml file into another as an elem

i want to insert bellow file using xsl...
<CustomerOrder xmlns="http://eai.yash.com/eBiz/CustomerOrder">
      <Request>
        <OrderDetails_Input>
          <Ordered_Products>
            <Product_Id/>
            <Product_Model/>
            <Product_Price/>
            <Product_Quantity>1</Product_Quantity>
          </Ordered_Products>
          <Customer_Details>
            <Customer_Id>1234</Customer_Id>
            <Customer_Name/>
            <Instance_Id/>
            <Session_Id/>
          </Customer_Details>
          <Delivery_Address>
            <Owners_Name/>
            <Door_No/>
            <Street_Name/>
            <Locality_Name/>
            <City_Name/>
            <State_Name/>
            <Country_Name/>
            <Postal_Code/>
            <Tel_No/>
          </Delivery_Address>
        </OrderDetails_Input>
      </Request>
</CustomerOrder>

as an child element of <Payload> in bellow file
please guide me....

<ns1:EaiEnvelope xmlns:ns1="http://eai.yash.com/eBiz/Envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ns1:Domain>ebiz</ns1:Domain>
  <ns1:Sender>webserviceteam</ns1:Sender>
  <ns1:UserType>service1</ns1:UserType>
  <ns1:UserId>venkat</ns1:UserId>
  <ns1:Password>1234</ns1:Password>
  <ns1:MessageId>123</ns1:MessageId>
  <ns1:CorrelationId>12354</ns1:CorrelationId>
  <ns1:Payload>

  </ns1:Payload>
</ns1:EaiEnvelope>

thanks in advance...

sushant
Reply With Quote
  #2 (permalink)  
Old December 20th, 2007, 10:01 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I suspect you should investigate the document() function, then you can do something like <xsl:value-of select="document('other.xml')"/>

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old December 20th, 2007, 10:34 AM
Registered User
 
Join Date: Dec 2007
Location: hyderabad, AP, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i have tried but its not working properly.... i want whole xml file as an child of <Paylaod>
  i m prity new to xml can u plz solve by code????

thanks

sushant
Reply With Quote
  #4 (permalink)  
Old December 20th, 2007, 10:51 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

You need to use
Code:
<xsl:copy-of select="document('customerorder.xml')/*"/>
So start with the identity transformation template
Code:
<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>
then add a template for that Payload element that copies the other document in e.g.
Code:
<xsl:template match="ns1:Payload"
  xmlns:ns1="http://eai.yash.com/eBiz/Envelope">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsl:copy-of select="document('customerorder.xml')/*"/>
  </xsl:copy>
</xsl:template>
Reply With Quote
  #5 (permalink)  
Old December 20th, 2007, 11:00 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Please take the time to explain your problem more clearly. Also take the time to write proper sentences rather than text shorthand - it's a basic courtesy to your readers. If you tried something and it didn't work, please explain what you tried and what happened\, so we can help you understand what you did wrong.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #6 (permalink)  
Old December 21st, 2007, 01:04 AM
Registered User
 
Join Date: Dec 2007
Location: hyderabad, AP, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

its working....

 thanks.:)

sushant
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
append/insert data to xml file andhiez XML 5 April 18th, 2008 11:13 AM
insert in xsl template some xml file ratzko XSLT 2 January 16th, 2008 08:30 AM
Create XML file - According to the Value, add elem remya1000 General .NET 0 October 2nd, 2007 11:03 PM
insert data param into xml from external file alexshiell XSLT 0 January 24th, 2006 01:47 PM
How to insert a new element in XML file? kmriyad C# 1 September 20th, 2004 09:18 AM



All times are GMT -4. The time now is 03:22 PM.


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