all groups > dotnet xml > march 2007 >
You're in the

dotnet xml

group:

Default attributes from DTD while transformation


Default attributes from DTD while transformation mahesh.nimbalkar NO[at]SPAM gmail.com
3/26/2007 1:04:02 PM
dotnet xml:
When I transform XML, XSLT automatically adds extra attributes to the
node which are declared in DTD (default DTD attributes) . I just want
XSLT not to add these extra default attributes from DTD.

See refname and shortname attributes are added to node automatically
after transformation.

Please let me know how to fix this.

----------------------------------------------------------------------------------------------------------------------------------------------------------------
<?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>angela.kendall@nielsenbookdata.co.uk</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>
Re: Default attributes from DTD while transformation Bjoern Hoehrmann
3/27/2007 12:00:00 AM
* mahesh.nimbalkar@gmail.com wrote in microsoft.public.dotnet.xml:
[quoted text, click to view]

Then you have to remove the document type declaration or otherwise
instruct your transformation engine and/or parser to not read the
external subset. There is no way to achieve this using only XSLT.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
Re: Default attributes from DTD while transformation mahesh.nimbalkar NO[at]SPAM gmail.com
3/27/2007 2:38:41 PM
Thank you for the reply Bjoern Hoehrmann

I am using following VB.NET code for transformation. Please tell me
where I can set flag for not to resolve externals.

Sub Main(ByVal args() As String)
Dim xmlInputFile As String =3D args(0)
Dim xslInputFile As String =3D args(1)
Const xmlOutputFile As String =3D "output.xml"

Dim xPathDoc As New XPathDocument(xmlInputFile)
Dim transform As New XslCompiledTransform()
Dim results As Stream =3D Nothing

Try
results =3D File.Create(xmlOutputFile)

Dim argsList As New XsltArgumentList()
Dim dateAndTime As New MyDateTime()
argsList.AddExtensionObject("urn:MyDateTime", dateAndTime)

transform.Load(xslInputFile)
transform.Transform(xPathDoc, argsList, results)

Catch ex As Exception
results.Flush()
Console.WriteLine(ex)
Finally
results.Close()
End Try
End Sub

[quoted text, click to view]

Re: Default attributes from DTD while transformation mahesh.nimbalkar NO[at]SPAM gmail.com
3/27/2007 3:43:29 PM
I do not have control to that DTD. It is managed by one organization
for Book industry.

[quoted text, click to view]

Re: Default attributes from DTD while transformation Peter Flynn
3/27/2007 11:38:28 PM
[quoted text, click to view]

Or change the DTD so that those attributes become optional instead of
compulsory.

///Peter
--
Re: Default attributes from DTD while transformation Helena Kotas [MSFT]
3/30/2007 3:54:02 PM
You can disable to DTD from loading if you set the XmlResolver to null. To do
so you will need to load the XPathDocument from a reader:

Dim reader As New XmlTextReader(xmlInputFile)
reader.XmlResolver = null
Dim xPathDoc As New XPathDocument(reader)

HTH,
Helena Kotas, MSFT

[quoted text, click to view]
AddThis Social Bookmark Button