Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old December 20th, 2007, 09:34 AM
Registered User
 
Join Date: Dec 2007
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
 
Old December 20th, 2007, 10:01 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
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 -/
 
Old December 20th, 2007, 10:34 AM
Registered User
 
Join Date: Dec 2007
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
 
Old December 20th, 2007, 10:51 AM
Friend of Wrox
 
Join Date: Nov 2007
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>
 
Old December 20th, 2007, 11:00 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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
 
Old December 21st, 2007, 01:04 AM
Registered User
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

its working....

 thanks.:)

sushant





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





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