xslt多级分组 - 从一种xml格式转换为另一种格式

时间:2012-04-26 14:02:33

标签: xslt xslt-1.0 xslt-2.0 xslt-grouping

我的xslt转换遇到了问题。源xml具有多级节点。

我想将xml从一个表单转换为其他表单

这是我的xslt

  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="text() | @*">
    <xsl:apply-templates select="text() | @*"/>
  </xsl:template>
  <xsl:template match="SalesOrder">
    <SalesOrder z:Id="i1" xmlns="http://schemas.datacontract.org/2004/07/Eurofins.Genomics.Egsp.Xbo.OrderManagement" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
      <BillTo>
        <xsl:value-of select="BillTo"/>
      </BillTo>
      <OrderReferenceCustomer>
        <xsl:value-of select="OrderID"/>
      </OrderReferenceCustomer>
      <OrderStatus>
        <xsl:value-of select="OrderStatus"/>
      </OrderStatus>
      <Contact>
        <xsl:value-of select="BillTo"/>
      </Contact>
      <ShipTo>
        <xsl:value-of select="ShipTo"/>
      </ShipTo>
      <SoldTo>
        <xsl:value-of select="SoldTo"/>
      </SoldTo>
      <SoldBy>
        <xsl:value-of select="SoldBy"/>
      </SoldBy>
      <Site>
        <xsl:value-of select="OrderSite"/>
      </Site>
      <ConfirmedDate>
        <xsl:value-of select="ConfirmedDate"/>
      </ConfirmedDate>
      <xsl:apply-templates/>
    </SalesOrder>
  </xsl:template>
  <xsl:template match="FulfilmentInfo">
    <FulfillmentInfo>
      <TestOrder>
        <xsl:value-of select="TestOrder"/>
      </TestOrder>
      <PromotionCode>
        <xsl:value-of select="PromotionCode"/>
      </PromotionCode>
      <FirstConfirmedDate>
        <xsl:value-of select="FirstConfirmedDate"/>
      </FirstConfirmedDate>
      <DocumentationLanguage>
        <xsl:value-of select="DocumentationLanguage"/>
      </DocumentationLanguage>
    </FulfillmentInfo>
  </xsl:template>
  <xsl:template match="PaymentOptions">
    <PaymentInformations>
        <xsl:apply-templates />
    </PaymentInformations>
  </xsl:template>
  <xsl:template match="PaymentOptions">
    <PaymentInformation>
      <PaymentMethod>
        <xsl:value-of select="PaymentMethod"/>
      </PaymentMethod>
    </PaymentInformation>
  </xsl:template>
</xsl:stylesheet>

我的目标转换xml就像这样

<SalesOrder>
      <BillTo>anyType</BillTo>
      <OrderReferenceCustomer>anyType</OrderReferenceCustomer>
      <OrderStatus>InCart</OrderStatus>
      <Contact>anyType</Contact>
      <ShipTo>anyType</ShipTo>
      <SoldTo>anyType</SoldTo>
      <SoldBy>anyType</SoldBy>
      <Site>TKY</Site>
      <ConfirmedDate>1900-01-01T01:01:01+05:30</ConfirmedDate>
      <FulfillmentInfo xmlns="">
        <TestOrder>true</TestOrder>
        <PromotionCode>anyType</PromotionCode>
        <FirstConfirmedDate>1900-01-01T01:01:01+05:30</FirstConfirmedDate>
        <DocumentationLanguage>anyType</DocumentationLanguage>
      </FulfillmentInfo>
      <PaymentInformation xmlns="">
        <PaymentMethod>CC</PaymentMethod>
      </PaymentInformation>
      <PaymentInformation xmlns="">
        <PaymentMethod>PO</PaymentMethod>
      </PaymentInformation>
      <PaymentInformation xmlns="">
        <PaymentMethod>EVO</PaymentMethod>
      </PaymentInformation>
    </SalesOrder>

这是预期的结果,我希望从我的转型

<SalesOrder>
  <BillTo>anyType</BillTo>
  <OrderReferenceCustomer>anyType</OrderReferenceCustomer>
  <OrderStatus>InCart</OrderStatus>
  <Contact>anyType</Contact>
  <ShipTo>anyType</ShipTo>
  <SoldTo>anyType</SoldTo>
  <SoldBy>anyType</SoldBy>
  <Site>TKY</Site>
  <ConfirmedDate>1900-01-01T01:01:01+05:30</ConfirmedDate>
  <FulfillmentInfo xmlns="">
    <TestOrder>true</TestOrder>
    <PromotionCode>anyType</PromotionCode>
    <FirstConfirmedDate>1900-01-01T01:01:01+05:30</FirstConfirmedDate>
    <DocumentationLanguage>anyType</DocumentationLanguage>
  </FulfillmentInfo>
<PaymentInformations>
  <PaymentInformation xmlns="">
    <PaymentMethod>CC</PaymentMethod>
  </PaymentInformation>
  <PaymentInformation xmlns="">
    <PaymentMethod>PO</PaymentMethod>
  </PaymentInformation>
  <PaymentInformation xmlns="">
    <PaymentMethod>EVO</PaymentMethod>
  </PaymentInformation>
</PaymentInformations>
</SalesOrder>

我还想知道这是否是将xml从一种格式转换为另一种格式的正确方法。

这是我的输入XML:

<?xml version="1.0" encoding="utf-8"?>
<GenomicOrder>
  <SalesOrder>
    <OrderID>anyType</OrderID>
    <ProductionOrderCount>1</ProductionOrderCount>
    <OrderStatus>InCart</OrderStatus>
    <Contact>anyType</Contact>
    <ShipTo>anyType</ShipTo>
    <SoldTo>anyType</SoldTo>
    <BillTo>anyType</BillTo>
    <SoldBy>anyType</SoldBy>
    <OrderSite>TKY</OrderSite>
    <ConfirmedDate>1900-01-01T01:01:01+05:30</ConfirmedDate>
    <OrderRef>
      <Type>ERP</Type>
      <OrderRef>OrderRef1</OrderRef>
    </OrderRef>
    <OrderRef>
      <Type>CUSTOMER</Type>
      <OrderRef>OrderRef2</OrderRef>
    </OrderRef>
    <OrderRef>
      <Type>EXT</Type>
      <OrderRef>OrderRef3</OrderRef>
    </OrderRef>
    <FulfilmentInfo>
      <TestOrder>true</TestOrder>
      <PromotionCode>anyType</PromotionCode>
      <Comment>
        <CommentType>anyType</CommentType>
        <CommentText>anyType</CommentText>
        <CommentDate>1900-01-01T01:01:01+05:30</CommentDate>
        <InternalComment>true</InternalComment>
      </Comment>
      <Comment>
        <CommentType>anyType</CommentType>
        <CommentText>anyType</CommentText>
        <CommentDate>0001-01-01T00:00:00+05:30</CommentDate>
        <InternalComment>false</InternalComment>
      </Comment>
      <Comment>
        <CommentType>anyType</CommentType>
        <CommentText>anyType</CommentText>
        <CommentDate>9999-12-31T23:59:59.9999999+05:30</CommentDate>
        <InternalComment>true</InternalComment>
      </Comment>
      <Shipment>
        <shippingMethod>anyType</shippingMethod>
        <shippingCarrier>anyType</shippingCarrier>
        <shippingAccount>anyType</shippingAccount>
        <condolidatedShipment>anyType</condolidatedShipment>
        <ShippingCost>
          <NetPrice>1</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </ShippingCost>
      </Shipment>
      <FirstConfirmedDate>1900-01-01T01:01:01+05:30</FirstConfirmedDate>
      <DocumentationLanguage>anyType</DocumentationLanguage>
      <GiftCertificate>anyType</GiftCertificate>
      <GiftCertificate>anyType</GiftCertificate>
      <GiftCertificate>anyType</GiftCertificate>
    </FulfilmentInfo>
    <PaymentOptions>
      <PaymentMethod>CC</PaymentMethod>
      <TransactionId>anyType</TransactionId>
      <CardID>anyType</CardID>
      <PoNumber>PoNumber1</PoNumber>
      <Amount>1</Amount>
    </PaymentOptions>
    <PaymentOptions>
      <PaymentMethod>PO</PaymentMethod>
      <TransactionId>anyType</TransactionId>
      <CardID>anyType</CardID>
      <PoNumber>PoNumber2</PoNumber>
      <Amount>-3.40282347E+38</Amount>
    </PaymentOptions>
    <PaymentOptions>
      <PaymentMethod>EVO</PaymentMethod>
      <TransactionId>anyType</TransactionId>
      <CardID>anyType</CardID>
      <PoNumber>PoNumber3</PoNumber>
      <Amount>3.40282347E+38</Amount>
    </PaymentOptions>
  </SalesOrder>
  <ProductionOrder>
    <extpectedDeliveryDate>anyType</extpectedDeliveryDate>
    <ProductionSite>TKY</ProductionSite>
    <ProductionSystem>anyType</ProductionSystem>
    <BusinessUnit>GSY</BusinessUnit>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>1900-01-01T01:01:01+05:30</CommentDate>
      <InternalComment>true</InternalComment>
    </Comment>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>0001-01-01T00:00:00+05:30</CommentDate>
      <InternalComment>false</InternalComment>
    </Comment>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>9999-12-31T23:59:59.9999999+05:30</CommentDate>
      <InternalComment>true</InternalComment>
    </Comment>
    <Price>
      <NetPrice>1</NetPrice>
      <Tax>anyType</Tax>
      <Currency>anyType</Currency>
      <CalculationDate>anyType</CalculationDate>
    </Price>
    <Shipment>
      <shippingMethod>anyType</shippingMethod>
      <shippingCarrier>anyType</shippingCarrier>
      <shippingAccount>anyType</shippingAccount>
      <condolidatedShipment>anyType</condolidatedShipment>
      <ShippingCost>
        <NetPrice>-3.40282347E+38</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </ShippingCost>
    </Shipment>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>1</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>1</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>-3.40282347E+38</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>-3.40282347E+38</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>3.40282347E+38</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>3.40282347E+38</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <ProductionOrderStatus>CART</ProductionOrderStatus>
  </ProductionOrder>
  <ProductionOrder>
    <extpectedDeliveryDate>anyType</extpectedDeliveryDate>
    <ProductionSite>EBE</ProductionSite>
    <ProductionSystem>anyType</ProductionSystem>
    <BusinessUnit>OLIGO</BusinessUnit>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>1899-11-30T01:01:01+05:30</CommentDate>
      <InternalComment>false</InternalComment>
    </Comment>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>1900-02-02T01:01:01+05:30</CommentDate>
      <InternalComment>true</InternalComment>
    </Comment>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>0001-02-02T00:00:00+05:30</CommentDate>
      <InternalComment>false</InternalComment>
    </Comment>
    <Price>
      <NetPrice>-3.40282347E+38</NetPrice>
      <Tax>anyType</Tax>
      <Currency>anyType</Currency>
      <CalculationDate>anyType</CalculationDate>
    </Price>
    <Shipment>
      <shippingMethod>anyType</shippingMethod>
      <shippingCarrier>anyType</shippingCarrier>
      <shippingAccount>anyType</shippingAccount>
      <condolidatedShipment>anyType</condolidatedShipment>
      <ShippingCost>
        <NetPrice>3.40282347E+38</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </ShippingCost>
    </Shipment>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>-0.100000024</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>0.100000024</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>2.1</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>2.1</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>3.40282347E+38</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>-3.40282347E+38</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <ProductionOrderStatus>ORDERED</ProductionOrderStatus>
  </ProductionOrder>
  <ProductionOrder>
    <extpectedDeliveryDate>anyType</extpectedDeliveryDate>
    <ProductionSite>HSV</ProductionSite>
    <ProductionSystem>anyType</ProductionSystem>
    <BusinessUnit>NGS</BusinessUnit>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>9999-11-29T23:59:59.9999999+05:30</CommentDate>
      <InternalComment>true</InternalComment>
    </Comment>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>1899-10-29T01:01:01+05:30</CommentDate>
      <InternalComment>false</InternalComment>
    </Comment>
    <Comment>
      <CommentType>anyType</CommentType>
      <CommentText>anyType</CommentText>
      <CommentDate>1900-03-06T01:01:01+05:30</CommentDate>
      <InternalComment>true</InternalComment>
    </Comment>
    <Price>
      <NetPrice>3.40282347E+38</NetPrice>
      <Tax>anyType</Tax>
      <Currency>anyType</Currency>
      <CalculationDate>anyType</CalculationDate>
    </Price>
    <Shipment>
      <shippingMethod>anyType</shippingMethod>
      <shippingCarrier>anyType</shippingCarrier>
      <shippingAccount>anyType</shippingAccount>
      <condolidatedShipment>anyType</condolidatedShipment>
      <ShippingCost>
        <NetPrice>-0.100000024</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </ShippingCost>
    </Shipment>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>3.40282347E+38</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>3.40282347E+38</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>1.2</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>1.2</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <OrderItems>
      <ItemName>anyType</ItemName>
      <Quantity>anyType</Quantity>
      <UnitPrice>
        <NetPrice>3.2</NetPrice>
        <Tax>anyType</Tax>
        <Currency>anyType</Currency>
        <CalculationDate>anyType</CalculationDate>
      </UnitPrice>
      <KitNumber>anyType</KitNumber>
      <KitComponents>
        <KitComponentNumber>anyType</KitComponentNumber>
        <Quantity>anyType</Quantity>
        <Price>
          <NetPrice>3.2</NetPrice>
          <Tax>anyType</Tax>
          <Currency>anyType</Currency>
          <CalculationDate>anyType</CalculationDate>
        </Price>
      </KitComponents>
      <ProductionInformation>
        <GeneItem>anyType</GeneItem>
      </ProductionInformation>
    </OrderItems>
    <ProductionOrderStatus>REVIEW</ProductionOrderStatus>
  </ProductionOrder>
</GenomicOrder>

这是我期望从我的转变中得到的结果

    <?xml version="1.0" encoding="utf-8"?>
<SalesOrder xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Eurofins.Genomics.Egsp.Xbo.OrderManagement" z:Id="i1">
  <CreatedByClient >testString</CreatedByClient>
  <CreatedByUser >testString</CreatedByUser>
  <CreatedOn >2012-04-26T17:44:15.4556116+05:30</CreatedOn>
  <ExchangeableBusinessObjectId >00000000-0000-0000-0000-000000000000</ExchangeableBusinessObjectId>
  <IncrementalId >0</IncrementalId>
  <InstanceStatus >Active</InstanceStatus>
  <ModifiedByClient  i:nil="true"/>
  <ModifiedByUser  i:nil="true"/>
  <ModifiedOn  i:nil="true"/>
  <BillTo>self</BillTo>
  <ConfirmedDate>2012-04-26T17:44:15.4546116+05:30</ConfirmedDate>
  <Contact z:Id="i2">
    <CreatedByClient >TestApplication</CreatedByClient>
    <CreatedByUser >Ram</CreatedByUser>
    <CreatedOn >2012-04-26T17:44:15.4546116+05:30</CreatedOn>
    <ExchangeableBusinessObjectId >00000000-0000-0000-0000-000000000000</ExchangeableBusinessObjectId>
    <IncrementalId >0</IncrementalId>
    <InstanceStatus >Active</InstanceStatus>
    <ModifiedByClient  i:nil="true"/>
    <ModifiedByUser  i:nil="true"/>
    <ModifiedOn  i:nil="true"/>
    <Address z:Id="i3">
      <CreatedByClient  i:nil="true"/>
      <CreatedByUser  i:nil="true"/>
      <CreatedOn >2012-04-26T17:44:15.4556116+05:30</CreatedOn>
      <ExchangeableBusinessObjectId >00000000-0000-0000-0000-000000000000</ExchangeableBusinessObjectId>
      <IncrementalId >0</IncrementalId>
      <InstanceStatus >Active</InstanceStatus>
      <ModifiedByClient  i:nil="true"/>
      <ModifiedByUser  i:nil="true"/>
      <ModifiedOn  i:nil="true"/>
      <AddressType>Contact</AddressType>
      <City>Bangalore</City>
      <Country>India</Country>
      <CustomField1 i:nil="true"/>
      <CustomField2 i:nil="true"/>
      <Fax i:nil="true"/>
      <FirstName i:nil="true"/>
      <LastName i:nil="true"/>
      <Line1 i:nil="true"/>
      <Line2 i:nil="true"/>
      <Line3 i:nil="true"/>
      <Mobile i:nil="true"/>
      <Phone i:nil="true"/>
      <Recipient i:nil="true"/>
      <State i:nil="true"/>
      <Street i:nil="true"/>
      <Title i:nil="true"/>
      <Zip i:nil="true"/>
    </Address>
    <EmailAddress>ramprasad@eurofins.com</EmailAddress>
    <VatId i:nil="true"/>
  </Contact>
  <FulfillmentInfo z:Id="i4">
    <CreatedByClient  i:nil="true"/>
    <CreatedByUser >ram</CreatedByUser>
    <CreatedOn  i:nil="true"/>
    <ExchangeableBusinessObjectId >00000000-0000-0000-0000-000000000000</ExchangeableBusinessObjectId>
    <IncrementalId >0</IncrementalId>
    <InstanceStatus >Active</InstanceStatus>
    <ModifiedByClient  i:nil="true"/>
    <ModifiedByUser  i:nil="true"/>
    <ModifiedOn  i:nil="true"/>
    <Comments i:nil="true"/>
    <DocumentationLanguage>testString</DocumentationLanguage>
    <FirstConfirmedDate>2012-04-26T17:44:15.4536116+05:30</FirstConfirmedDate>
    <GiftCertificate i:nil="true"/>
    <GiftCertificates i:nil="true"/>
    <PromotionCode>testString</PromotionCode>
    <TestOrder>false</TestOrder>
  </FulfillmentInfo>
  <OrderReference>test</OrderReference>
  <OrderReferenceCustomer>Order123456</OrderReferenceCustomer>
  <OrderReferenceExternal>testext</OrderReferenceExternal>
  <OrderStatus>Review</OrderStatus>
  <PaymentInformations>
    <PaymentInformation z:Id="i5">
      <CreatedByClient >testString</CreatedByClient>
      <CreatedByUser >testString</CreatedByUser>
      <CreatedOn >2012-04-26T17:44:15.4536116+05:30</CreatedOn>
      <ExchangeableBusinessObjectId >00000000-0000-0000-0000-000000000000</ExchangeableBusinessObjectId>
      <IncrementalId >0</IncrementalId>
      <InstanceStatus >Active</InstanceStatus>
      <ModifiedByClient  i:nil="true"/>
      <ModifiedByUser  i:nil="true"/>
      <ModifiedOn  i:nil="true"/>
      <Amount>123</Amount>
      <EvoCardId>ER</EvoCardId>
      <PaymentMethod>EvoCard</PaymentMethod>
      <PoNumber i:nil="true"/>
      <TransactionID i:nil="true"/>
    </PaymentInformation>
  </PaymentInformations>

1 个答案:

答案 0 :(得分:0)

也许只是对转换流程有一点控制权?像这样的东西:

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

  <xsl:template match="SalesOrder">
    <SalesOrder>
    ...
      <xsl:apply-templates select="FulfilmentInfo"/>
      <PaymentInformations>
          <xsl:apply-templates select="PaymentOptions/PaymentMethod"/>
      </PaymentInformations>
    </SalesOrder>
  </xsl:template>
  ...
  <xsl:template match="PaymentMethod">
    <PaymentInformation>
      <PaymentMethod>
        <xsl:value-of select="."/>
      </PaymentMethod>
    </PaymentInformation>
  </xsl:template>
  ...

如果不是命名空间更改,您也可以使用<xsl:copy-of select="">而不是手动重新创建结构。