Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:53:22+00:00 2026-06-02T16:53:22+00:00

I have an xslt written for transforming from one xml format to the other.

  • 0

I have an xslt written for transforming from one xml format to the other.

my source file has multiple “production orders” and one “Sales Order”
my destination has only one “sales Order” which holds all production orders.

Here is my source xml format

 <GenomicOrder>
  <SalesOrder>
    ....
  </SalesOrder>
  <ProductionOrder>
    ....
  </ProductionOrder>
  <ProductionOrder>
    ....
  </ProductionOrder>
  <ProductionOrder>
    ....
  </ProductionOrder>
</GenomicOrder>

my destination xml format is as below

<GenomicOrder>
  <SalesOrder>
    ....
  <ProductionOrder>
    ....
  </ProductionOrder>
  <ProductionOrder>
    ....
  </ProductionOrder>
  <ProductionOrder>
    ....
  </ProductionOrder>
  </SalesOrder>
</GenomicOrder>

My deserialization code is as below

DataContractSerializer ser = new DataContractSerializer(typeof(SalesOrder));
            FileStream fs =
                new FileStream(
                    @"C:\realsample.xml",
                    FileMode.Open);
            XmlDictionaryReader reader1 = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());

            //Deserialize the data and read it from the instance.
            SalesOrder parent = (SalesOrder)ser.ReadObject(reader1, true);

            reader1.Close();

My successful sales order xslt Transformation is as below

<xsl:template match="/">
    <SalesOrder>
      <xsl:apply-templates select="GenomicOrder/SalesOrder"/>
      <ProductionOrders>
        <xsl:apply-templates select="GenomicOrder/ProductionOrder"/>
      </ProductionOrders>
    </SalesOrder>
  </xsl:template>

SalesOrder.OrderId=1234;
SalesOrder.ProductionOrder =null;

My successful production order xslt Transformation is as below

<xsl:template match="/">
        <SalesOrder>
          <ProductionOrders>
            <xsl:apply-templates select="GenomicOrder/ProductionOrder"/>
          </ProductionOrders>
          <xsl:apply-templates select="GenomicOrder/SalesOrder"/>
        </SalesOrder>
</xsl:template>

SalesOrder.OrderId=null;
SalesOrder.ProductionOrder.OrderRef = 12345;

is there any changes that i can do to deserialize all the objects in one pass. I have transformations written for both “GenomicOrder/ProductionOrder” and “GenomicOrder/SalesOrder”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:53:24+00:00Added an answer on June 2, 2026 at 4:53 pm

    I am not sure I understand the problem, assuming you want to wrap all elements following a SalesOrder element you can use an approach like

    <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="2.0">
    
      <xsl:strip-space elements="*"/>
      <xsl:output indent="yes"/>
    
      <xsl:template match="GenomicOrder">
        <xsl:copy>
          <xsl:for-each-group select="*" group-starting-with="SalesOrder">
            <SalesOrder>
              <xsl:copy-of select="node(), current-group() except ."/>
            </SalesOrder>
          </xsl:for-each-group>
        </xsl:copy>
      </xsl:template>
    
    </xsl:stylesheet>
    

    That XSLT 2.0 stylesheet, when run with Saxon 9.4 on the input

     <GenomicOrder>
      <SalesOrder>
        ....
      </SalesOrder>
      <ProductionOrder>
        ....
      </ProductionOrder>
      <ProductionOrder>
        ....
      </ProductionOrder>
      <ProductionOrder>
        ....
      </ProductionOrder>
    </GenomicOrder>
    

    outputs

    <GenomicOrder>
       <SalesOrder>
        ....
      <ProductionOrder>
        ....
      </ProductionOrder>
          <ProductionOrder>
        ....
      </ProductionOrder>
          <ProductionOrder>
        ....
      </ProductionOrder>
       </SalesOrder>
    </GenomicOrder>
    

    You might need to post more details on your XML input structure if my suggestion does not help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .xslt that translates xml from one form to another (I'm not
I have an XSLT stylesheet that transforms an XML file to JSON format and
I have written an xslt that reads some xml file names and does some
I have an XML file that I am transforming via XSLT. I am passing
I have XSLT 1.0 standard. I have one dynamic XML from server which is
I have written a C# code for triggering an XML to XML (XSLT) transformation.
I have the following node I need to parse using XSLT 1.0 from xml
I have an xml file which describes (among other things) elements with attribute values
I want to convert one xml format to another xml format by using xslt
I have written a small application in HTML/CSS/JQuery/XML/XSLT that ends up writing to an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.