Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
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 October 6th, 2006, 09:41 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replacing New Root Node

I have the following XML document:

<fxEnvelope>
  <header>
    <message>
      <exchangeID>ForestExpress</exchangeID>
      <messageID>PPB54706959</messageID>
      <arrivalTime>2006-08-25T18:19:05GMT</arrivalTime>
      <subject>Order</subject>
      <payloadType>X</payloadType>
    </message>
    <from>
      <orgID>xpx001</orgID>
      <messageID>84-P17871_119017</messageID>
    </from>
    <to>
      <orgID>apl002</orgID>
    </to>
  </header>
  <body><Order>
      <OrderHeader>
        <OrderNumber>
          <BuyerOrderNumber>84-P17871</BuyerOrderNumber>
        </OrderNumber>
        <OrderIssueDate>20060825T00:00:00</OrderIssueDate>
        <OrderReferences>
          <OtherOrderReferences>
            <ListOfReferenceCoded>
              <ReferenceCoded>
                <ReferenceTypeCoded>TrackingNumber</ReferenceTypeCoded>
                <PrimaryReference>
                  <Reference>
                    <RefNum>119017</RefNum>
                  </Reference>
                </PrimaryReference>
              </ReferenceCoded>
              <ReferenceCoded>
                <ReferenceTypeCoded>PurchaseOrderNumber</ReferenceTypeCoded>
                <PrimaryReference>
                  <Reference>
                    <RefNum>84-P17871</RefNum>
                  </Reference>
                </PrimaryReference>
              </ReferenceCoded>
              <ReferenceCoded>
                <ReferenceTypeCoded>Other</ReferenceTypeCoded>
                <ReferenceTypeCodedOther>XpedxLegacyVendorNumber </ReferenceTypeCodedOther>
                <PrimaryReference>
                  <Reference>
                    <RefNum>103012</RefNum>
                  </Reference>
                </PrimaryReference>
              </ReferenceCoded>
            </ListOfReferenceCoded>
          </OtherOrderReferences>
        </OrderReferences>
        <Purpose>
          <PurposeCoded>Original</PurposeCoded>
        </Purpose>
        <OrderType>
          <OrderTypeCoded>DirectShip</OrderTypeCoded>
        </OrderType>
        <OrderCurrency>
          <Currency>
            <CurrencyCoded>USD</CurrencyCoded>
          </Currency>
        </OrderCurrency>
        <OrderLanguage>
          <Language>
            <LanguageCoded>en</LanguageCoded>
          </Language>
        </OrderLanguage>
        <OrderDates>
          <RequestedDeliverByDate>20060829T00:00:00</RequestedDeliverByDate>
        </OrderDates>
        <OrderParty>
          <BuyerParty>
            <Party>
              <PartyID>
                <Identifier>
                  <Agency>
                    <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
                  </Agency>
                  <Ident>0024665550000</Ident>
                </Identifier>
              </PartyID>
              <NameAddress>
                <Name1>xpedx - Syracuse</Name1>
                <Street>6485 Ridings Rd</Street>
                <StreetSupplement1></StreetSupplement1>
                <PostalCode>13206-0000</PostalCode>
                <City>SYRACUSE</City>
                <Region>
                  <RegionCoded>USNY</RegionCoded>
                </Region>
                <Country>
                  <CountryCoded>US</CountryCoded>
                </Country>
              </NameAddress>
              <OrderContact>
                <Contact>
                  <ContactName>Michele Sidello LPC-Syracuse </ContactName>
                  <ListOfContactNumber>
                    <ContactNumber>
                      <ContactNumberValue>3154329949</ContactNumberValue>
                      <ContactNumberTypeCoded>FaxNumber</ContactNumberTypeCoded>
                    </ContactNumber>
                  </ListOfContactNumber>
                </Contact>
              </OrderContact>
            </Party>
          </BuyerParty>
          <SellerParty>
            <Party>
              <PartyID>
                <Identifier>
                  <Agency>
                    <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
                  </Agency>
                  <Ident>apl002 </Ident>
                </Identifier>
              </PartyID>
            </Party>
          </SellerParty>
          <ShipToParty>
            <Party>
              <PartyID>
                <Identifier>
                  <Agency>
                    <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
                  </Agency>
                  <Ident>80840008411679000001</Ident>
                </Identifier>
              </PartyID>
              <NameAddress>
                <Name1>SYRACUSE UNIV PRINTING SVCS</Name1>
                <Street>HAWKINS BUILDING</Street>
                <StreetSupplement1>1600 JAMESVILLE AVE</StreetSupplement1>
                <PostalCode>13244</PostalCode>
                <City>SYRACUSE</City>
                <Region>
                  <RegionCoded>USNY</RegionCoded>
                </Region>
                <Country>
                  <CountryCoded>US</CountryCoded>
                </Country>
              </NameAddress>
              <OrderContact>
                <Contact>
                  <ContactName></ContactName>
                </Contact>
              </OrderContact>
            </Party>
          </ShipToParty>
          <BillToParty>
            <Party>
              <PartyID>
                <Identifier>
                  <Agency>
                    <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
                  </Agency>
                  <Ident>0030276040000</Ident>
                </Identifier>
              </PartyID>
              <NameAddress>
                <Name1>xpedx/Syracuse</Name1>
                <Street>SEND INVOICES TO: P.O. BOX 1337</Street>
                <StreetSupplement1></StreetSupplement1>
                <PostalCode>171051337</PostalCode>
                <City>HARRISBURG</City>
                <Region>
                  <RegionCoded>USPA</RegionCoded>
                </Region>
                <Country>
                  <CountryCoded>US</CountryCoded>
                </Country>
              </NameAddress>
            </Party>
          </BillToParty>
        </OrderParty>
        <ListOfTransport>
          <Transport>
            <TransportID>1</TransportID>
            <TransportMode>
              <TransportModeCoded>BestWay-ShippersOption</TransportModeCoded>
            </TransportMode>
          </Transport>
        </ListOfTransport>
        <OrderTermsOfDelivery>
          <TermsOfDelivery>
            <TermsOfDeliveryFunctionCoded>DeliveryCondition</TermsOfDeliveryFunctionCoded>
            <ShipmentMethodOfPaymentCoded>DefinedByBuyerAndSel ler</ShipmentMethodOfPaymentCoded>
            <Location>
              <LocationQualifierCoded>Other</LocationQualifierCoded>
              <LocationIdentifier>
                <LocID>
                  <Identifier>
                    <Agency>
                      <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
                    </Agency>
                    <Ident>N/A</Ident>
                  </Identifier>
                </LocID>
              </LocationIdentifier>
            </Location>
          </TermsOfDelivery>
        </OrderTermsOfDelivery>
        <OrderHeaderNote>ship all from wisconsin direct please reference customer purchase order k112785 ref 26138 price quoted by Barb plus 75.00 freight chge</OrderHeaderNote>
      </OrderHeader>
      <OrderDetail>
        <ListOfItemDetail>
          <ItemDetail>
            <BaseItemDetail>
              <LineItemNum>
                <BuyerLineItemNum>0100</BuyerLineItemNum>
              </LineItemNum>
              <LineItemType>
                <LineItemTypeCoded>Other</LineItemTypeCoded>
                <LineItemTypeCodedOther>Direct</LineItemTypeCodedOther>
              </LineItemType>
              <ItemIdentifiers>
                <PartNumbers>
                  <BuyerPartNumber>
                    <PartNum>
                      <PartID>2199069</PartID>
                    </PartNum>
                  </BuyerPartNumber>
                  <ManufacturerPartNumber>
                    <PartID>1294</PartID>
                  </ManufacturerPartNumber>
                </PartNumbers>
                <ItemDescription>APPLETON RADIANT FLUO C1S 10pt 8.5&quot;x 11&quot; 29M PEACH</ItemDescription>
              </ItemIdentifiers>
              <TotalQuantity>
                <Quantity>
                  <QuantityValue>1</QuantityValue>
                  <UnitOfMeasurement>
                    <UOMCoded>CT</UOMCoded>
                  </UnitOfMeasurement>
                </Quantity>
              </TotalQuantity>
            </BaseItemDetail>
            <PricingDetail>
              <ListOfPrice>
                <Price>
                  <UnitPrice>
                    <UnitPriceValue>220.4</UnitPriceValue>
                    <UnitOfMeasurement>
                      <UOMCoded>HW</UOMCoded>
                    </UnitOfMeasurement>
                  </UnitPrice>
                </Price>
              </ListOfPrice>
            </PricingDetail>
            <DeliveryDetail>
              <ListOfScheduleLine>
                <ScheduleLine>
                  <Quantity>
                    <QuantityValue>1</QuantityValue>
                    <UnitOfMeasurement>
                      <UOMCoded>CT</UOMCoded>
                    </UnitOfMeasurement>
                  </Quantity>
                </ScheduleLine>
              </ListOfScheduleLine>
            </DeliveryDetail>
            <LineItemNote></LineItemNote>
          </ItemDetail>
          <ItemDetail>
            <BaseItemDetail>
              <LineItemNum>
                <BuyerLineItemNum>0110</BuyerLineItemNum>
              </LineItemNum>
              <LineItemType>
                <LineItemTypeCoded>Other</LineItemTypeCoded>
                <LineItemTypeCodedOther>Direct</LineItemTypeCodedOther>
              </LineItemType>
              <ItemIdentifiers>
                <PartNumbers>
                  <BuyerPartNumber>
                    <PartNum>
                      <PartID>2199069</PartID>
                    </PartNum>
                  </BuyerPartNumber>
                  <ManufacturerPartNumber>
                    <PartID>1294</PartID>
                  </ManufacturerPartNumber>
                </PartNumbers>
                <ItemDescription>APPLETON RADIANT FLUO C1S 10pt 8.5&quot;x 11&quot; 29M PEACH</ItemDescription>
              </ItemIdentifiers>
              <TotalQuantity>
                <Quantity>
                  <QuantityValue>1</QuantityValue>
                  <UnitOfMeasurement>
                    <UOMCoded>CT</UOMCoded>
                  </UnitOfMeasurement>
                </Quantity>
              </TotalQuantity>
            </BaseItemDetail>
            <PricingDetail>
              <ListOfPrice>
                <Price>
                  <UnitPrice>
                    <UnitPriceValue>220.4</UnitPriceValue>
                    <UnitOfMeasurement>
                      <UOMCoded>HW</UOMCoded>
                    </UnitOfMeasurement>
                  </UnitPrice>
                </Price>
              </ListOfPrice>
            </PricingDetail>
            <DeliveryDetail>
              <ListOfScheduleLine>
                <ScheduleLine>
                  <Quantity>
                    <QuantityValue>1</QuantityValue>
                    <UnitOfMeasurement>
                      <UOMCoded>CT</UOMCoded>
                    </UnitOfMeasurement>
                  </Quantity>
                </ScheduleLine>
              </ListOfScheduleLine>
            </DeliveryDetail>
            <LineItemNote>COST $220.40/CWT PLUS FREIGHT CHGE OF $75.00 INCLUDED IN THE RESALE REFERENCE CUSTOMER PO# K112785 REF# 26138</LineItemNote>
          </ItemDetail>
        </ListOfItemDetail>
      </OrderDetail>
      <OrderSummary>
        <NumberOfLines>2</NumberOfLines>
        <TotalAmount>
          <MonetaryValue>
            <MonetaryAmount>204.54</MonetaryAmount>
          </MonetaryValue>
        </TotalAmount>
      </OrderSummary>
    </Order></body>
</fxEnvelope>

I am trying to extract only the <Order> to </Order> portion and adding a namespace tag to the <Order>. I am using the following XSLT:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="rrn:org.xcbl:schemas/xcbl/v3_0/xcbl30.xsd">

<xsl:template match="Order">
<Order>
          <xsl:copy-of select="."/>
</Order>
 </xsl:template>

 <xsl:template match="message | from | to" />

 </xsl:stylesheet>

I get the following output when using the current XSLT:

<?xml version="1.0"?>
<Order xmlns="rrn:org.xcbl:schemas/xcbl/v3_0/xcbl30.xsd">
<Order xmlns="">
<OrderHeader>
<OrderNumber>
<BuyerOrderNumber>84-P17871</BuyerOrderNumber>
</OrderNumber>
<OrderIssueDate>20060825T00:00:00</OrderIssueDate>
<OrderReferences>
<OtherOrderReferences>
<ListOfReferenceCoded>
<ReferenceCoded>
<ReferenceTypeCoded>TrackingNumber</ReferenceTypeCoded>
<PrimaryReference>
<Reference>
<RefNum>119017</RefNum>
</Reference>
</PrimaryReference>
</ReferenceCoded>
<ReferenceCoded>
<ReferenceTypeCoded>PurchaseOrderNumber</ReferenceTypeCoded>
<PrimaryReference>
<Reference>
<RefNum>84-P17871</RefNum>
</Reference>
</PrimaryReference>
</ReferenceCoded>
<ReferenceCoded>
<ReferenceTypeCoded>Other</ReferenceTypeCoded>
<ReferenceTypeCodedOther>XpedxLegacyVendorNumber </ReferenceTypeCodedOther>
<PrimaryReference>
<Reference>
<RefNum>103012</RefNum>
</Reference>
</PrimaryReference>
</ReferenceCoded>
</ListOfReferenceCoded>
</OtherOrderReferences>
</OrderReferences>
<Purpose>
<PurposeCoded>Original</PurposeCoded>
</Purpose>
<OrderType>
<OrderTypeCoded>DirectShip</OrderTypeCoded>
</OrderType>
<OrderCurrency>
<Currency>
<CurrencyCoded>USD</CurrencyCoded>
</Currency>
</OrderCurrency>
<OrderLanguage>
<Language>
<LanguageCoded>en</LanguageCoded>
</Language>
</OrderLanguage>
<OrderDates>
<RequestedDeliverByDate>20060829T00:00:00</RequestedDeliverByDate>
</OrderDates>
<OrderParty>
<BuyerParty>
<Party>
<PartyID>
<Identifier>
<Agency>
<AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
</Agency>
<Ident>0024665550000</Ident>
</Identifier>
</PartyID>
<NameAddress>
<Name1>xpedx - Syracuse</Name1>
<Street>6485 Ridings Rd</Street>
<StreetSupplement1></StreetSupplement1>
<PostalCode>13206-0000</PostalCode>
<City>SYRACUSE</City>
<Region>
<RegionCoded>USNY</RegionCoded>
</Region>
<Country>
<CountryCoded>US</CountryCoded>
</Country>
</NameAddress>
<OrderContact>
<Contact>
<ContactName>Michele Sidello LPC-Syracuse </ContactName>
<ListOfContactNumber>
<ContactNumber>
<ContactNumberValue>3154329949</ContactNumberValue>
<ContactNumberTypeCoded>FaxNumber</ContactNumberTypeCoded>
</ContactNumber>
</ListOfContactNumber>
</Contact>
</OrderContact>
</Party>
</BuyerParty>
<SellerParty>
<Party>
<PartyID>
<Identifier>
<Agency>
<AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
</Agency>
<Ident>apl002 </Ident>
</Identifier>
</PartyID>
</Party>
</SellerParty>
<ShipToParty>
<Party>
<PartyID>
<Identifier>
<Agency>
<AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
</Agency>
<Ident>80840008411679000001</Ident>
</Identifier>
</PartyID>
<NameAddress>
<Name1>SYRACUSE UNIV PRINTING SVCS</Name1>
<Street>HAWKINS BUILDING</Street>
<StreetSupplement1>1600 JAMESVILLE AVE</StreetSupplement1>
<PostalCode>13244</PostalCode>
<City>SYRACUSE</City>
<Region>
<RegionCoded>USNY</RegionCoded>
</Region>
<Country>
<CountryCoded>US</CountryCoded>
</Country>
</NameAddress>
<OrderContact>
<Contact>
<ContactName></ContactName>
</Contact>
</OrderContact>
</Party>
</ShipToParty>
<BillToParty>
<Party>
<PartyID>
<Identifier>
<Agency>
<AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
</Agency>
<Ident>0030276040000</Ident>
</Identifier>
</PartyID>
<NameAddress>
<Name1>xpedx/Syracuse</Name1>
<Street>SEND INVOICES TO: P.O. BOX 1337</Street>
<StreetSupplement1></StreetSupplement1>
<PostalCode>171051337</PostalCode>
<City>HARRISBURG</City>
<Region>
<RegionCoded>USPA</RegionCoded>
</Region>
<Country>
<CountryCoded>US</CountryCoded>
</Country>
</NameAddress>
</Party>
</BillToParty>
</OrderParty>
<ListOfTransport>
<Transport>
<TransportID>1</TransportID>
<TransportMode>
<TransportModeCoded>BestWay-ShippersOption</TransportModeCoded>
</TransportMode>
</Transport>
</ListOfTransport>
<OrderTermsOfDelivery>
<TermsOfDelivery>
<TermsOfDeliveryFunctionCoded>DeliveryCondition</TermsOfDeliveryFunctionCoded>
<ShipmentMethodOfPaymentCoded>DefinedByBuyerAndSel ler</ShipmentMethodOfPaymentCoded>
<Location>
<LocationQualifierCoded>Other</LocationQualifierCoded>
<LocationIdentifier>
<LocID>
<Identifier>
<Agency>
<AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded>
</Agency>
<Ident>N/A</Ident>
</Identifier>
</LocID>
</LocationIdentifier>
</Location>
</TermsOfDelivery>
</OrderTermsOfDelivery>
<OrderHeaderNote>ship all from wisconsin direct please reference customer purchase order k112785 ref 26138 price quoted by Barb plus 75.00 freight chge</OrderHeaderNote>
</OrderHeader>
<OrderDetail>
<ListOfItemDetail>
<ItemDetail>
<BaseItemDetail>
<LineItemNum>
<BuyerLineItemNum>0100</BuyerLineItemNum>
</LineItemNum>
<LineItemType>
<LineItemTypeCoded>Other</LineItemTypeCoded>
<LineItemTypeCodedOther>Direct</LineItemTypeCodedOther>
</LineItemType>
<ItemIdentifiers>
<PartNumbers>
<BuyerPartNumber>
<PartNum>
<PartID>2199069</PartID>
</PartNum>
</BuyerPartNumber>
<ManufacturerPartNumber>
<PartID>1294</PartID>
</ManufacturerPartNumber>
</PartNumbers>
<ItemDescription>APPLETON RADIANT FLUO C1S 10pt 8.5"x 11" 29M PEACH</ItemDescription>
</ItemIdentifiers>
<TotalQuantity>
<Quantity>
<QuantityValue>1</QuantityValue>
<UnitOfMeasurement>
<UOMCoded>CT</UOMCoded>
</UnitOfMeasurement>
</Quantity>
</TotalQuantity>
</BaseItemDetail>
<PricingDetail>
<ListOfPrice>
<Price>
<UnitPrice>
<UnitPriceValue>220.4</UnitPriceValue>
<UnitOfMeasurement>
<UOMCoded>HW</UOMCoded>
</UnitOfMeasurement>
</UnitPrice>
</Price>
</ListOfPrice>
</PricingDetail>
<DeliveryDetail>
<ListOfScheduleLine>
<ScheduleLine>
<Quantity>
<QuantityValue>1</QuantityValue>
<UnitOfMeasurement>
<UOMCoded>CT</UOMCoded>
</UnitOfMeasurement>
</Quantity>
</ScheduleLine>
</ListOfScheduleLine>
</DeliveryDetail>
<LineItemNote></LineItemNote>
</ItemDetail>
<ItemDetail>
<BaseItemDetail>
<LineItemNum>
<BuyerLineItemNum>0110</BuyerLineItemNum>
</LineItemNum>
<LineItemType>
<LineItemTypeCoded>Other</LineItemTypeCoded>
<LineItemTypeCodedOther>Direct</LineItemTypeCodedOther>
</LineItemType>
<ItemIdentifiers>
<PartNumbers>
<BuyerPartNumber>
<PartNum>
<PartID>2199069</PartID>
</PartNum>
</BuyerPartNumber>
<ManufacturerPartNumber>
<PartID>1294</PartID>
</ManufacturerPartNumber>
</PartNumbers>
<ItemDescription>APPLETON RADIANT FLUO C1S 10pt 8.5"x 11" 29M PEACH</ItemDescription>
</ItemIdentifiers>
<TotalQuantity>
<Quantity>
<QuantityValue>1</QuantityValue>
<UnitOfMeasurement>
<UOMCoded>CT</UOMCoded>
</UnitOfMeasurement>
</Quantity>
</TotalQuantity>
</BaseItemDetail>
<PricingDetail>
<ListOfPrice>
<Price>
<UnitPrice>
<UnitPriceValue>220.4</UnitPriceValue>
<UnitOfMeasurement>
<UOMCoded>HW</UOMCoded>
</UnitOfMeasurement>
</UnitPrice>
</Price>
</ListOfPrice>
</PricingDetail>
<DeliveryDetail>
<ListOfScheduleLine>
<ScheduleLine>
<Quantity>
<QuantityValue>1</QuantityValue>
<UnitOfMeasurement>
<UOMCoded>CT</UOMCoded>
</UnitOfMeasurement>
</Quantity>
</ScheduleLine>
</ListOfScheduleLine>
</DeliveryDetail>
<LineItemNote>COST $220.40/CWT PLUS FREIGHT CHGE OF $75.00 INCLUDED IN THE RESALE REFERENCE CUSTOMER PO# K112785 REF# 26138</LineItemNote>
</ItemDetail>
</ListOfItemDetail>
</OrderDetail>
<OrderSummary>
<NumberOfLines>2</NumberOfLines>
<TotalAmount>
<MonetaryValue>
<MonetaryAmount>204.54</MonetaryAmount>
</MonetaryValue>
</TotalAmount>
</OrderSummary>
</Order>
</Order>

How can I eliminate the duplicate <Order> </Order> tags while preserving the namespace that is added to the root <Order> tag?



Reply With Quote
  #2 (permalink)  
Old October 6th, 2006, 10:06 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Do you want all the elements underneath the new Order root to be in the same namespace as Order?


--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old October 6th, 2006, 10:29 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, but I only need the namespace specified within the <Order> tag.

Reply With Quote
  #4 (permalink)  
Old October 6th, 2006, 10:49 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

As you don't have any attributes to worry about, nor mixed content, the following should work;
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:apply-templates select="/*/body/Order"/>
  </xsl:template>
  <xsl:template match="Order">
    <Order xmlns="rrn:org.xcbl:schemas/xcbl/v3_0/xcbl30.xsd">
      <xsl:apply-templates/>
    </Order>
  </xsl:template>
  <xsl:template match="Order//*">
    <xsl:element name="{local-name()}" namespace="rrn:org.xcbl:schemas/xcbl/v3_0/xcbl30.xsd">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
I think Michael Kay could produce amore elegant and robust version though.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #5 (permalink)  
Old October 6th, 2006, 11:17 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Works great! I would like to understand a couple of things, however.

1. So the select="/*/body/Order"/ extracts beginning only at <Order>?

2. The template match="Order//*" - what is that communicating? Does it extract only the <Order> tag with the namespace and remove the second <Order> tag that is created?

Thanks for your help.

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
Dynamically cha nging root node!!!!!!! rakesh XSLT 4 July 29th, 2008 09:31 AM
The reference node is not a child of this node.XSL XMLUser XSLT 2 February 25th, 2008 05:22 AM
root node should not be expanded at page load Hannibal ASP.NET 2.0 Basics 0 November 28th, 2006 10:52 AM
SiteMapDataSource won't find my root node... thenoseknows ASP.NET 2.0 Professional 0 October 31st, 2006 04:22 PM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM



All times are GMT -4. The time now is 07:48 PM.


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