2012-04-26 80 views
0

我正面临着我的xslt转换问题。源xml具有多级节点。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>[email protected]</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> 
+0

考虑使用XSLT为该输入样本发布XML输入的样本和要创建的输出。而且'libxslt'和'xslt-2.0'的标签会让我困惑,因为libxslt是一个XSLT 1.0处理器。所以请澄清一下你想使用的XSLT版本。 – 2012-04-26 14:11:13

+0

我想要在xslt-2.0中进行转换 – KRP 2012-04-26 14:25:17

+0

想要的输出包含不在提供的XML文档中的值。请编辑并提供一个现实的,非矛盾的例子。 – 2012-04-27 02:16:01

回答

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="">,而不是重新创建的结构。

+0

我已经做出了更改以调用模板,但仍然保留着神秘感。我怎样才能把它重复付款方式 只调用一次的 <付款方法> 的 KRP 2012-04-26 14:57:31

+0

现在,有输入XML,我可以看到你有多个PaymentOptions,所以这就是为什么现在每个PaymentMethod – 2012-04-26 15:07:03

+0

@RamPrasadK我更新了我的答案。让我知道你是否愿意发布完整的XSLT,它可以完成你所说的你想要的功能。 – 2012-04-26 15:32:52

相关问题