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 March 23rd, 2007, 03:51 PM
Authorized User
 
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML to XML transform

I have following XML file and just want to rearrange it such that only \ONIXMessage\Product\RecordSourceName should come after \ONIXMessage\Product\RecordSourceIdentifier

-----------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ONIXMessage SYSTEM "http://www.editeur.org/onix/2.1/reference/onix-international.dtd">
<ONIXMessage>
  <Header>
    <FromEANNumber>5013546111661</FromEANNumber>
    <FromCompany>NielsenBookData</FromCompany>
    <FromPerson>Angela Kendall</FromPerson>
    <FromEmail>[email protected]</FromEmail>
    <SentDate>20061213</SentDate>
    <DefaultLanguageOfText>eng</DefaultLanguageOfText>
  </Header>
  <Product>
    <RecordReference>9780643091610</RecordReference>
    <NotificationType>03</NotificationType>
    <RecordSourceType>04</RecordSourceType>
    <RecordSourceName>Nielsen BookData</RecordSourceName>
    <RecordSourceIdentifierType>02</RecordSourceIdentifierType>
    <RecordSourceIdentifier>NBD</RecordSourceIdentifier>
    <ProductIdentifier>
      <ProductIDType>15</ProductIDType>
      <IDValue>9780643091610</IDValue>
    </ProductIdentifier>
    <ProductForm>BB</ProductForm>
    <Title>
      <TitleType>01</TitleType>
      <TitleText>The Nature of Plants</TitleText>
      <TitlePrefix>The</TitlePrefix>
      <TitleWithoutPrefix>Nature of Plants</TitleWithoutPrefix>
      <Subtitle>Habitats, Challenges and Adaptations</Subtitle>
    </Title>
    <Contributor>
      <SequenceNumber>1</SequenceNumber>
      <ContributorRole>A01</ContributorRole>
      <PersonName>John Dawson</PersonName>
      <PersonNameInverted>Dawson, John</PersonNameInverted>
      <NamesBeforeKey>John</NamesBeforeKey>
      <KeyNames>Dawson</KeyNames>
    </Contributor>
    <Contributor>
      <SequenceNumber>2</SequenceNumber>
      <ContributorRole>A01</ContributorRole>
      <PersonName>Rob Lucas</PersonName>
      <PersonNameInverted>Lucas, Rob</PersonNameInverted>
      <NamesBeforeKey>Rob</NamesBeforeKey>
      <KeyNames>Lucas</KeyNames>
    </Contributor>
    <EditionStatement>New title</EditionStatement>
    <NumberOfPages>314</NumberOfPages>
    <IllustrationsNote>colour photos &amp; illus</IllustrationsNote>
    <BASICMainSubject>GAR000000</BASICMainSubject>
    <BASICVersion>BISAC V2.8</BASICVersion>
    <BICMainSubject>VG</BICMainSubject>
    <BICVersion>1.1</BICVersion>
    <Subject>
      <SubjectSchemeIdentifier>01</SubjectSchemeIdentifier>
      <SubjectSchemeVersion>DC21</SubjectSchemeVersion>
      <SubjectCode>635</SubjectCode>
    </Subject>
    <AudienceCode>01</AudienceCode>
    <AudienceCode>05</AudienceCode>
    <OtherText>
      <TextTypeCode>02</TextTypeCode>
      <Text>There has always been interest in how animals live their lives - it is easy for us to identify with them. But there are many remarkable stories about plants that deserve to be told. This book tells how plants adapt to the challenges of their habitats.</Text>
    </OtherText>
    <Imprint>
      <NameCodeType>02</NameCodeType>
      <NameCodeTypeName>Nielsen BookData Org ID</NameCodeTypeName>
      <NameCodeValue>110001</NameCodeValue>
      <ImprintName>CSIRO Publishing</ImprintName>
    </Imprint>
    <Publisher>
      <NameCodeType>02</NameCodeType>
      <NameCodeTypeName>Nielsen BookData Org ID</NameCodeTypeName>
      <NameCodeValue>110001</NameCodeValue>
      <PublisherName>CSIRO Publishing</PublisherName>
    </Publisher>
    <CityOfPublication>Melbourne</CityOfPublication>
    <CountryOfPublication>AU</CountryOfPublication>
    <PublishingStatus>04</PublishingStatus>
    <PublicationDate>20050301</PublicationDate>
    <SalesRights>
      <SalesRightsType>02</SalesRightsType>
      <RightsCountry>AU NZ</RightsCountry>
    </SalesRights>
    <Measure>
      <MeasureTypeCode>01</MeasureTypeCode>
      <Measurement>260</Measurement>
      <MeasureUnitCode>mm</MeasureUnitCode>
    </Measure>
    <Measure>
      <MeasureTypeCode>02</MeasureTypeCode>
      <Measurement>185</Measurement>
      <MeasureUnitCode>mm</MeasureUnitCode>
    </Measure>
    <Measure>
      <MeasureTypeCode>08</MeasureTypeCode>
      <Measurement>1180</Measurement>
      <MeasureUnitCode>gr</MeasureUnitCode>
    </Measure>
    <SupplyDetail>
      <SupplierName>Supplier Unknown</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>GB</SupplyToCountry>
      <ProductAvailability>43</ProductAvailability>
      <Price>
        <PriceTypeCode>02</PriceTypeCode>
        <PriceAmount>0.50</PriceAmount>
        <CurrencyCode>GBP</CurrencyCode>
        <TaxRateCode1>Z</TaxRateCode1>
        <TaxRatePercent1>0.0</TaxRatePercent1>
        <TaxableAmount1>0.50</TaxableAmount1>
        <TaxAmount1>0.00</TaxAmount1>
      </Price>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier>
        <SupplierIDType>02</SupplierIDType>
        <IDTypeName>Nielsen BookData Org ID</IDTypeName>
        <IDValue>72077</IDValue>
      </SupplierIdentifier>
      <SupplierName>Eurospan Group Ltd</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>GB</SupplyToCountry>
      <ProductAvailability>99</ProductAvailability>
      <UnpricedItemType>04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier>
        <SupplierIDType>02</SupplierIDType>
        <IDTypeName>Nielsen BookData Org ID</IDTypeName>
        <IDValue>117189</IDValue>
      </SupplierIdentifier>
      <SupplierName>Antipodes Books and Beyond</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>US</SupplyToCountry>
      <ProductAvailability>99</ProductAvailability>
      <UnpricedItemType>04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier>
        <SupplierIDType>02</SupplierIDType>
        <IDTypeName>Nielsen BookData Org ID</IDTypeName>
        <IDValue>120778</IDValue>
      </SupplierIdentifier>
      <SupplierName>CSIRO Publishing</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>AU</SupplyToCountry>
      <ProductAvailability>99</ProductAvailability>
      <UnpricedItemType>04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier>
        <SupplierIDType>02</SupplierIDType>
        <IDTypeName>Nielsen BookData Org ID</IDTypeName>
        <IDValue>114396</IDValue>
      </SupplierIdentifier>
      <SupplierName>University and Reference Publishers' Services (UNIREPS)</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>AU</SupplyToCountry>
      <ProductAvailability>99</ProductAvailability>
      <UnpricedItemType>04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier>
        <SupplierIDType>02</SupplierIDType>
        <IDTypeName>Nielsen BookData Org ID</IDTypeName>
        <IDValue>123799</IDValue>
      </SupplierIdentifier>
      <SupplierName>Manaaki Whenua Press</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>NZ</SupplyToCountry>
      <ProductAvailability>99</ProductAvailability>
      <UnpricedItemType>04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier>
        <SupplierIDType>02</SupplierIDType>
        <IDTypeName>Nielsen BookData Org ID</IDTypeName>
        <IDValue>114396</IDValue>
      </SupplierIdentifier>
      <SupplierName>University and Reference Publishers' Services (UNIREPS)</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>NZ</SupplyToCountry>
      <ProductAvailability>99</ProductAvailability>
      <UnpricedItemType>04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier>
        <SupplierIDType>02</SupplierIDType>
        <IDTypeName>Nielsen BookData Org ID</IDTypeName>
        <IDValue>72077</IDValue>
      </SupplierIdentifier>
      <SupplierName>Eurospan Group Ltd</SupplierName>
      <SupplierRole>00</SupplierRole>
      <SupplyToCountry>IE</SupplyToCountry>
      <ProductAvailability>99</ProductAvailability>
      <UnpricedItemType>04</UnpricedItemType>
    </SupplyDetail>
    <MarketRepresentation>
      <AgentName>University and Reference Publishers' Services (UNIREPS)</AgentName>
      <AgentRole>07</AgentRole>
      <MarketCountry>AU</MarketCountry>
    </MarketRepresentation>
  </Product>
  </ONIXMessage>
 
Old March 23rd, 2007, 04:14 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Please create a smaller example that illustrates the essence of your problem. Noone has time to wade through this lot.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 23rd, 2007, 04:34 PM
Authorized User
 
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK. I have following XML.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ONIXMessage SYSTEM "http://www.editeur.org/onix/2.1/reference/onix-international.dtd">
<ONIXMessage>
  <Header>
    <FromEANNumber>5013546111661</FromEANNumber>
    <FromCompany>NielsenBookData</FromCompany>
    <FromPerson>Angela Kendall</FromPerson>
    <FromEmail>[email protected]</FromEmail>
    <SentDate>20061213</SentDate>
    <DefaultLanguageOfText>eng</DefaultLanguageOfText>
  </Header>
  <Product>
    <RecordReference>9780643091610</RecordReference>
    <NotificationType>03</NotificationType>
    <RecordSourceType>04</RecordSourceType>
    <RecordSourceName>Nielsen BookData</RecordSourceName>
    <RecordSourceIdentifierType>02</RecordSourceIdentifierType>
    <RecordSourceIdentifier>NBD</RecordSourceIdentifier>
    <ProductIdentifier>
      <ProductIDType>15</ProductIDType>
      <IDValue>9780643091610</IDValue>
    </ProductIdentifier>
   </Product>
</ONIXMessage>

 
Old March 23rd, 2007, 04:37 PM
Authorized User
 
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have following XML file and just want to rearrange it such that only \ONIXMessage\Product\RecordSourceName should come after \ONIXMessage\Product\RecordSourceIdentifier

This needs to be done avoiding hard coding element names in XSLT

-----------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ONIXMessage SYSTEM "http://www.editeur.org/onix/2.1/reference/onix-international.dtd">
<ONIXMessage>
  <Header>
    <FromEANNumber>5013546111661</FromEANNumber>
    <FromCompany>NielsenBookData</FromCompany>
    <FromPerson>Angela Kendall</FromPerson>
    <FromEmail>[email protected]</FromEmail>
    <SentDate>20061213</SentDate>
    <DefaultLanguageOfText>eng</DefaultLanguageOfText>
  </Header>
  <Product>
    <RecordReference>9780643091610</RecordReference>
    <NotificationType>03</NotificationType>
    <RecordSourceType>04</RecordSourceType>
    <RecordSourceName>Nielsen BookData</RecordSourceName>
    <RecordSourceIdentifierType>02</RecordSourceIdentifierType>
    <RecordSourceIdentifier>NBD</RecordSourceIdentifier>
    <ProductIdentifier>
      <ProductIDType>15</ProductIDType>
      <IDValue>9780643091610</IDValue>
    </ProductIdentifier>
   </Product>
</ONIXMessage>
 
Old March 23rd, 2007, 04:38 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Write a template rule for Product that copies children in the order you want them:

<xsl:template match="Product">
  <xsl:copy-of select="RecordReference"/>
  <xsl:copy-of select="NotificationType"/>
  etc
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 23rd, 2007, 04:52 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you don't want to identify RecordSourceName by name, how do you want to identify it? By content ("Nielsen BookData") perhaps? Or by position? (the 5th child)? You've got to refer to it somehow...

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 23rd, 2007, 05:23 PM
Authorized User
 
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot for the reply Michael.

I have written following XSL. Please look at the whole XML I have given in first post.

Now the only problem I am facing is that RecordReference and a few tags coming twice after <RecordSourceName> tag. I just do not want <RecordReference>, <NotificationType>, <RecordSourceType>, <RecordSourceName>, <RecordSourceIdentifierType> and <RecordSourceIdentifier> come again after first Product\RecordSourceName



<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:MyDateTime="urn:MyDateTime" exclude-result-prefixes="MyDateTime">

    <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" omit-xml-declaration="no" indent="yes"/>
    <xsl:output doctype-system="http://www.editeur.org/onix/2.1/reference/onix-international.dtd"/>

    <xsl:template match="/">
        <xsl:comment>Transformed by ONIX Loader to make this valid XML file on <xsl:value-of select="MyDateTime:ToString()"/></xsl:comment>

        <ONIXMessage>
            <Header>
                <xsl:apply-templates select="ONIXMessage/Header/node()" mode="Header"/>
            </Header>

            <Product>
                <xsl:apply-templates select="ONIXMessage/Product/RecordReference"/>
                <xsl:apply-templates select="ONIXMessage/Product/NotificationType"/>
                <xsl:apply-templates select="ONIXMessage/Product/RecordSourceType"/>
                <xsl:apply-templates select="ONIXMessage/Product/RecordSourceIdentifierType"/>
                <xsl:apply-templates select="ONIXMessage/Product/RecordSourceIdentifier"/>
                <xsl:apply-templates select="ONIXMessage/Product/RecordSourceName"/>

                <xsl:apply-templates select="ONIXMessage/Product/node()" mode="Product"/>
            </Product>
        </ONIXMessage>
    </xsl:template>

    <xsl:template match="*" mode="Header">
        <xsl:copy>
            <xsl:copy-of select="node()"/>
       </xsl:copy>
    </xsl:template>

    <xsl:template match="node()" mode="Product">
        <xsl:copy>
            <xsl:copy-of select="node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="*">
        <xsl:copy>
            <xsl:copy-of select="node()"/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>
 
Old March 23rd, 2007, 05:29 PM
Authorized User
 
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

output XML after transformation

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE ONIXMessage SYSTEM "http://www.editeur.org/onix/2.1/reference/onix-international.dtd">
<ONIXMessage>
  <Header>
    <FromEANNumber>5013546111661</FromEANNumber>
    <FromCompany>NielsenBookData</FromCompany>
    <FromPerson>Angela Kendall</FromPerson>
    <FromEmail>[email protected]</FromEmail>
    <SentDate>20061213</SentDate>
    <DefaultLanguageOfText>eng</DefaultLanguageOfText>
  </Header>
  <Product>
    <RecordReference>9780643091610</RecordReference>
    <NotificationType>03</NotificationType>
    <RecordSourceType>04</RecordSourceType>
    <RecordSourceIdentifierType>02</RecordSourceIdentifierType>
    <RecordSourceIdentifier>NBD</RecordSourceIdentifier>
    <RecordSourceName>Nielsen BookData</RecordSourceName>
    <RecordReference>9780643091610</RecordReference>
    <NotificationType>03</NotificationType>
    <RecordSourceType>04</RecordSourceType>
    <RecordSourceName>Nielsen BookData</RecordSourceName>
    <RecordSourceIdentifierType>02</RecordSourceIdentifierType>
    <RecordSourceIdentifier>NBD</RecordSourceIdentifier>
    <ProductIdentifier>
      <ProductIDType refname="ProductIDType" shortname="b221">15</ProductIDType>
      <IDValue refname="IDValue" shortname="b244">9780643091610</IDValue>
    </ProductIdentifier>
    <ProductForm>BB</ProductForm>
    <Title>
      <TitleType refname="TitleType" shortname="b202">01</TitleType>
      <TitleText refname="TitleText" shortname="b203">The Nature of Plants</TitleText>
      <TitlePrefix refname="TitlePrefix" shortname="b030">The</TitlePrefix>
      <TitleWithoutPrefix refname="TitleWithoutPrefix" shortname="b031">Nature of Plants</TitleWithoutPrefix>
      <Subtitle refname="Subtitle" shortname="b029">Habitats, Challenges and Adaptations</Subtitle>
    </Title>
    <Contributor>
      <SequenceNumber refname="SequenceNumber" shortname="b034">1</SequenceNumber>
      <ContributorRole refname="ContributorRole" shortname="b035">A01</ContributorRole>
      <PersonName refname="PersonName" shortname="b036">John Dawson</PersonName>
      <PersonNameInverted refname="PersonNameInverted" shortname="b037">Dawson, John</PersonNameInverted>
      <NamesBeforeKey refname="NamesBeforeKey" shortname="b039">John</NamesBeforeKey>
      <KeyNames refname="KeyNames" shortname="b040">Dawson</KeyNames>
    </Contributor>
    <Contributor>
      <SequenceNumber refname="SequenceNumber" shortname="b034">2</SequenceNumber>
      <ContributorRole refname="ContributorRole" shortname="b035">A01</ContributorRole>
      <PersonName refname="PersonName" shortname="b036">Rob Lucas</PersonName>
      <PersonNameInverted refname="PersonNameInverted" shortname="b037">Lucas, Rob</PersonNameInverted>
      <NamesBeforeKey refname="NamesBeforeKey" shortname="b039">Rob</NamesBeforeKey>
      <KeyNames refname="KeyNames" shortname="b040">Lucas</KeyNames>
    </Contributor>
    <EditionStatement>New title</EditionStatement>
    <NumberOfPages>314</NumberOfPages>
    <IllustrationsNote>colour photos &amp; illus</IllustrationsNote>
    <BASICMainSubject>GAR000000</BASICMainSubject>
    <BASICVersion>BISAC V2.8</BASICVersion>
    <BICMainSubject>VG</BICMainSubject>
    <BICVersion>1.1</BICVersion>
    <Subject>
      <SubjectSchemeIdentifier refname="SubjectSchemeIdentifier" shortname="b067">01</SubjectSchemeIdentifier>
      <SubjectSchemeVersion refname="SubjectSchemeVersion" shortname="b068">DC21</SubjectSchemeVersion>
      <SubjectCode refname="SubjectCode" shortname="b069">635</SubjectCode>
    </Subject>
    <AudienceCode>01</AudienceCode>
    <AudienceCode>05</AudienceCode>
    <OtherText>
      <TextTypeCode refname="TextTypeCode" shortname="d102">02</TextTypeCode>
      <Text refname="Text" shortname="d104">There has always been interest in how animals live their lives - it is easy for us to identify with them. But there are many remarkable stories about plants that deserve to be told. This book tells how plants adapt to the challenges of their habitats.</Text>
    </OtherText>
    <Imprint>
      <NameCodeType refname="NameCodeType" shortname="b241">02</NameCodeType>
      <NameCodeTypeName refname="NameCodeTypeName" shortname="b242">Nielsen BookData Org ID</NameCodeTypeName>
      <NameCodeValue refname="NameCodeValue" shortname="b243">110001</NameCodeValue>
      <ImprintName refname="ImprintName" shortname="b079">CSIRO Publishing</ImprintName>
    </Imprint>
    <Publisher>
      <NameCodeType refname="NameCodeType" shortname="b241">02</NameCodeType>
      <NameCodeTypeName refname="NameCodeTypeName" shortname="b242">Nielsen BookData Org ID</NameCodeTypeName>
      <NameCodeValue refname="NameCodeValue" shortname="b243">110001</NameCodeValue>
      <PublisherName refname="PublisherName" shortname="b081">CSIRO Publishing</PublisherName>
    </Publisher>
    <CityOfPublication>Melbourne</CityOfPublication>
    <CountryOfPublication>AU</CountryOfPublication>
    <PublishingStatus>04</PublishingStatus>
    <PublicationDate>20050301</PublicationDate>
    <SalesRights>
      <SalesRightsType refname="SalesRightsType" shortname="b089">02</SalesRightsType>
      <RightsCountry refname="RightsCountry" shortname="b090">AU NZ</RightsCountry>
    </SalesRights>
    <Measure>
      <MeasureTypeCode refname="MeasureTypeCode" shortname="c093">01</MeasureTypeCode>
      <Measurement refname="Measurement" shortname="c094">260</Measurement>
      <MeasureUnitCode refname="MeasureUnitCode" shortname="c095">mm</MeasureUnitCode>
    </Measure>
    <Measure>
      <MeasureTypeCode refname="MeasureTypeCode" shortname="c093">02</MeasureTypeCode>
      <Measurement refname="Measurement" shortname="c094">185</Measurement>
      <MeasureUnitCode refname="MeasureUnitCode" shortname="c095">mm</MeasureUnitCode>
    </Measure>
    <Measure>
      <MeasureTypeCode refname="MeasureTypeCode" shortname="c093">08</MeasureTypeCode>
      <Measurement refname="Measurement" shortname="c094">1180</Measurement>
      <MeasureUnitCode refname="MeasureUnitCode" shortname="c095">gr</MeasureUnitCode>
    </Measure>
    <SupplyDetail>
      <SupplierName refname="SupplierName" shortname="j137">Supplier Unknown</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">GB</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">43</ProductAvailability>
      <Price refname="Price" shortname="price">
        <PriceTypeCode refname="PriceTypeCode" shortname="j148">02</PriceTypeCode>
        <PriceAmount refname="PriceAmount" shortname="j151">0.50</PriceAmount>
        <CurrencyCode refname="CurrencyCode" shortname="j152">GBP</CurrencyCode>
        <TaxRateCode1 refname="TaxRateCode1" shortname="j153">Z</TaxRateCode1>
        <TaxRatePercent1 refname="TaxRatePercent1" shortname="j154">0.0</TaxRatePercent1>
        <TaxableAmount1 refname="TaxableAmount1" shortname="j155">0.50</TaxableAmount1>
        <TaxAmount1 refname="TaxAmount1" shortname="j156">0.00</TaxAmount1>
      </Price>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier refname="SupplierIdentifier" shortname="supplieridentifier">
        <SupplierIDType refname="SupplierIDType" shortname="j345">02</SupplierIDType>
        <IDTypeName refname="IDTypeName" shortname="b233">Nielsen BookData Org ID</IDTypeName>
        <IDValue refname="IDValue" shortname="b244">72077</IDValue>
      </SupplierIdentifier>
      <SupplierName refname="SupplierName" shortname="j137">Eurospan Group Ltd</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">GB</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">99</ProductAvailability>
      <UnpricedItemType refname="UnpricedItemType" shortname="j192">04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier refname="SupplierIdentifier" shortname="supplieridentifier">
        <SupplierIDType refname="SupplierIDType" shortname="j345">02</SupplierIDType>
        <IDTypeName refname="IDTypeName" shortname="b233">Nielsen BookData Org ID</IDTypeName>
        <IDValue refname="IDValue" shortname="b244">117189</IDValue>
      </SupplierIdentifier>
      <SupplierName refname="SupplierName" shortname="j137">Antipodes Books and Beyond</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">US</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">99</ProductAvailability>
      <UnpricedItemType refname="UnpricedItemType" shortname="j192">04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier refname="SupplierIdentifier" shortname="supplieridentifier">
        <SupplierIDType refname="SupplierIDType" shortname="j345">02</SupplierIDType>
        <IDTypeName refname="IDTypeName" shortname="b233">Nielsen BookData Org ID</IDTypeName>
        <IDValue refname="IDValue" shortname="b244">120778</IDValue>
      </SupplierIdentifier>
      <SupplierName refname="SupplierName" shortname="j137">CSIRO Publishing</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">AU</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">99</ProductAvailability>
      <UnpricedItemType refname="UnpricedItemType" shortname="j192">04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier refname="SupplierIdentifier" shortname="supplieridentifier">
        <SupplierIDType refname="SupplierIDType" shortname="j345">02</SupplierIDType>
        <IDTypeName refname="IDTypeName" shortname="b233">Nielsen BookData Org ID</IDTypeName>
        <IDValue refname="IDValue" shortname="b244">114396</IDValue>
      </SupplierIdentifier>
      <SupplierName refname="SupplierName" shortname="j137">University and Reference Publishers' Services (UNIREPS)</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">AU</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">99</ProductAvailability>
      <UnpricedItemType refname="UnpricedItemType" shortname="j192">04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier refname="SupplierIdentifier" shortname="supplieridentifier">
        <SupplierIDType refname="SupplierIDType" shortname="j345">02</SupplierIDType>
        <IDTypeName refname="IDTypeName" shortname="b233">Nielsen BookData Org ID</IDTypeName>
        <IDValue refname="IDValue" shortname="b244">123799</IDValue>
      </SupplierIdentifier>
      <SupplierName refname="SupplierName" shortname="j137">Manaaki Whenua Press</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">NZ</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">99</ProductAvailability>
      <UnpricedItemType refname="UnpricedItemType" shortname="j192">04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier refname="SupplierIdentifier" shortname="supplieridentifier">
        <SupplierIDType refname="SupplierIDType" shortname="j345">02</SupplierIDType>
        <IDTypeName refname="IDTypeName" shortname="b233">Nielsen BookData Org ID</IDTypeName>
        <IDValue refname="IDValue" shortname="b244">114396</IDValue>
      </SupplierIdentifier>
      <SupplierName refname="SupplierName" shortname="j137">University and Reference Publishers' Services (UNIREPS)</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">NZ</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">99</ProductAvailability>
      <UnpricedItemType refname="UnpricedItemType" shortname="j192">04</UnpricedItemType>
    </SupplyDetail>
    <SupplyDetail>
      <SupplierIdentifier refname="SupplierIdentifier" shortname="supplieridentifier">
        <SupplierIDType refname="SupplierIDType" shortname="j345">02</SupplierIDType>
        <IDTypeName refname="IDTypeName" shortname="b233">Nielsen BookData Org ID</IDTypeName>
        <IDValue refname="IDValue" shortname="b244">72077</IDValue>
      </SupplierIdentifier>
      <SupplierName refname="SupplierName" shortname="j137">Eurospan Group Ltd</SupplierName>
      <SupplierRole refname="SupplierRole" shortname="j292">00</SupplierRole>
      <SupplyToCountry refname="SupplyToCountry" shortname="j138">IE</SupplyToCountry>
      <ProductAvailability refname="ProductAvailability" shortname="j396">99</ProductAvailability>
      <UnpricedItemType refname="UnpricedItemType" shortname="j192">04</UnpricedItemType>
    </SupplyDetail>
    <MarketRepresentation>
      <AgentName refname="AgentName" shortname="j401">University and Reference Publishers' Services (UNIREPS)</AgentName>
      <AgentRole refname="AgentRole" shortname="j402">07</AgentRole>
      <MarketCountry refname="MarketCountry" shortname="j403">AU</MarketCountry>
    </MarketRepresentation>
  </Product>
</ONIXMessage>

 
Old March 25th, 2007, 06:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I assume you realise that it is the instruction

<xsl:apply-templates select="ONIXMessage/Product/node()" mode="Product"/>

that is outputting the unwanted nodes (because node() selects all the children of the Product). You need to change this to only output those elements that you want to output at this point.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform xml to xml changing one tag. surfer97301 XSLT 2 April 21st, 2010 05:14 PM
XML to XML transform (Simplified) nmahesh567 XSLT 2 March 24th, 2007 07:57 AM
XSLT read through XML to transform another XML dendenx2 XSLT 8 July 7th, 2005 08:18 PM
Transform XML to XML wene XSLT 8 December 17th, 2004 11:28 AM
Transform XML to XML using XSLT Mr.D XSLT 2 September 7th, 2004 02:13 PM





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