I've a XML and an XSLT v2.0 transformation to apply to it.
I need to output the resulting HTML (essentialy a table structure for despatch advice document) to the container page.
The container page is an ASP.NET page with some controls and a Tab
control (from Telerik) that I want to use to put the final document for viewing it.
My problem is that the transformation returns a full HTML page starting from <html>
tag.
How can I filter only the content that I need?
On another similar project I used an ASP.NET Xml Server Control to both apply the transformation (XSLT v1.0) and automatically obtain the document view. This is the code:
XmlDocument xd;
using (MemoryStream ms = new MemoryStream(file))
{
xd = new XmlDocument();
xd.Load(ms);
}
XDocument InvoiceXDocument = new XDocument();
using (var nodeReader = new XmlNodeReader(xd))
{
nodeReader.MoveToContent();
InvoiceXDocument = XDocument.Load(nodeReader);
}
invoiceViewer.TransformSource = @"C:\path\to\transformation.xslt";
invoiceViewer.DocumentContent = InvoiceXDocument.ToString(); // XDocument object of the XML invoice
Since my new XSLT is a XSLT v2.0 I can't use it anymore. So I switched to Saxon.
This is my actual transformation code using Saxon:
Processor processor = new Processor();
XsltCompiler compiler = processor.NewXsltCompiler();
XsltExecutable executable;
executable = compiler.Compile(new Uri(xsltFilePath));
StringWriter output = new StringWriter();
Serializer serializer = new Serializer();
serializer.SetOutputWriter(output);
XsltTransformer transformer = executable.Load();
transformer.SetInputStream(input, new Uri("file:///XSLTValidURI"));
transformer.Run(serializer);
return output.ToString();
How can I obtain the same result using Saxon library?
UPDATE 2016/08/30
The XML files comes from Peppol European Business Document Service (see PEPPOL)
This is the XML to transform (with italian comments).
<?xml version="1.0" encoding="UTF-8"?>
<DespatchAdvice xmlns="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>urn:www.cenbii.eu:transaction:biitrns016:ver1.0:extended:urn:www.peppol.eu:bis:peppol30a:ver1.0:extended:urn:www.ubl-italia.org:spec:ddt:ver2.1</cbc:CustomizationID>
<cbc:ProfileID>urn:www.cenbii.eu:profile:bii30:ver2.0</cbc:ProfileID>
<!--Identificativo DDT. Obbligatorio-->
<cbc:ID>DDT-2015-123</cbc:ID>
<!--Data DDT. Obbligatorio-->
<cbc:IssueDate>2015-10-29</cbc:IssueDate>
<!--Orario DDT. Opzionale. Se usato inserire informazione-->
<cbc:IssueTime>08:00:50</cbc:IssueTime>
<!--Campo note in testata. Opzionale. Se usato inserire informazione-->
<cbc:Note>Prova Note in Testata</cbc:Note>
<!--Identificativo riferimento ad un singolo ordine. Opzionale. Se usato inserire informazione-->
<cac:OrderReference>
<cbc:ID>ORD-2015-321</cbc:ID>
<cbc:IssueDate>2015-10-25</cbc:IssueDate>
<!--Tipo ordine. Opzionale. Se usato inserire informazione-->
<cbc:OrderTypeCode listID="UNCL1001">221</cbc:OrderTypeCode>
</cac:OrderReference>
<!--Speditore. Organizzazione che fornisce la merce o servizi. Obbligatorio-->
<cac:DespatchSupplierParty>
<cac:Party>
<cac:PartyIdentification>
<!--CF PI speditore. Obbligatorio-->
<cbc:ID schemeID="IT:VAT">IT123456789</cbc:ID>
</cac:PartyIdentification>
<!--Azienda speditore. Obbligatorio-->
<cac:PartyName>
<cbc:Name>Notier</cbc:Name>
</cac:PartyName>
<!--Contatto persona di riferimento. Opzionale. Se usato inserire informazione-->
<cac:Contact>
<cbc:Name>Magazzino</cbc:Name>
<cbc:Telephone>05155999</cbc:Telephone>
<cbc:Telefax>05155999</cbc:Telefax>
<cbc:ElectronicMail>CasellaPostaSpeditore@indirizzo.it</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
</cac:DespatchSupplierParty>
<!--Consegnatario. Organizzazione alla quale verranno spediti i prodotti. Obbligatorio-->
<cac:DeliveryCustomerParty>
<cac:Party>
<!--Codice IPA consegnatario Ausl Cesena. Opzionale. Se usato inserire informazione-->
<cbc:EndpointID schemeID="IT:IPA">9921:IT0L06J9</cbc:EndpointID>
<cac:PartyIdentification>
<!--CF PI consegnatario. Obbligatorio-->
<cbc:ID schemeID="IT:VAT">123456789</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<!--Azienda consegnatario. Obbligatorio-->
<cbc:Name>Nome Azienda Consegnatario</cbc:Name>
</cac:PartyName>
<!--Indirizzo consegnatario. Opzionale. Se usato inserire informazione-->
<cac:PostalAddress>
<cbc:ID>AB01</cbc:ID>
<cbc:StreetName>Via</cbc:StreetName>
<cbc:AdditionalStreetName>Inforazioni aggiuntive all'indirizzo</cbc:AdditionalStreetName>
<cbc:CityName>Bologna</cbc:CityName>
<cbc:PostalZone>40100</cbc:PostalZone>
<cbc:CountrySubentity>BO</cbc:CountrySubentity>
<cac:Country>
<cbc:IdentificationCode listID="ISO3166-1:Alpha2">IT</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
</cac:Party>
<!--Contatto persona di riferimento. Opzionale. Se usato inserire informazione-->
<cac:DeliveryContact>
<!--Informazioni persona di riferimento. Opzionale. Se usato inserire informazione-->
<cbc:Name>Nome Persona o Magazzino</cbc:Name>
<cbc:Telephone>05155999</cbc:Telephone>
<cbc:Telefax>05155999</cbc:Telefax>
<cbc:ElectronicMail>CasellaPostaConsegnatario@indirizzo.it</cbc:ElectronicMail>
</cac:DeliveryContact>
</cac:DeliveryCustomerParty>
<!--Acquirente. Chi acquista la merce. Opzionale. Se usato inserire informazione-->
<cac:BuyerCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<!--CF PI acquirente. Obbligatorio-->
<cbc:ID schemeID="IT:CF">123456789</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<!--Azienda acquirente. Obbligatorio-->
<cbc:Name>Nome Acquirente</cbc:Name>
</cac:PartyName>
</cac:Party>
</cac:BuyerCustomerParty>
<!--Venditore. Chi vende la merce o i servizi. Opzionale. Se usato inserire informazione-->
<cac:SellerSupplierParty>
<cac:Party>
<cac:PartyIdentification>
<!--CF PI venditore. Obbligatorio-->
<cbc:ID schemeID="IT:VAT">IT123456789</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<!--Azienda venditore. Obbligatorio-->
<cbc:Name>Nome o Descrizione del Magazzino, Venditore</cbc:Name>
</cac:PartyName>
<!--Contatto persona di riferimento. Opzionale. Se usato inserire informazione-->
<cac:Contact>
<!--Infomrazioni Persona di Riferimento. Opzionale. Se usato inserire informazione-->
<cbc:Name>Nome Persona o Magazzino di Riferimento se Presente</cbc:Name>
<cbc:Telephone>05155999</cbc:Telephone>
<cbc:Telefax>05155999</cbc:Telefax>
<cbc:ElectronicMail>CasellaPostaVenditore@indirizzo.it</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
</cac:SellerSupplierParty>
<!--Committente. Chi eventualmente riceve e consuma la merce. Opzionale. Se usato inserire informazione-->
<cac:OriginatorCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<!--CF PI committente. Obbligatorio-->
<cbc:ID schemeID="IT:CF">123456789</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<!--Azienda committente. Obbligatorio-->
<cbc:Name>Nome o Descrizione del Magazzino, Committente</cbc:Name>
</cac:PartyName>
</cac:Party>
</cac:OriginatorCustomerParty>
<!--Gestione spedizione della merce. Opzionale. Se usato inserire informazione-->
<cac:Shipment>
<!--Identificatore spedizione, se non presente ID usare 'NA'. Obbligatorio-->
<cbc:ID>AB01</cbc:ID>
<!--Informazioni gestione spedizione. Opzionale-->
<cbc:Information>Inserire Descrizione Spedizione</cbc:Information>
<cbc:GrossWeightMeasure unitCode="KGM">100</cbc:GrossWeightMeasure>
<cbc:GrossVolumeMeasure unitCode="MTQ">15</cbc:GrossVolumeMeasure>
<cbc:TotalTransportHandlingUnitQuantity>25</cbc:TotalTransportHandlingUnitQuantity>
<!--Informazioni di trasporto sulla spedizione. Opzionale. Se usato inserire informazione-->
<cac:Consignment>
<cbc:ID>SPED100</cbc:ID>
<!--Descrizione del veicolo. Opzionale. Se usato inserire informazione-->
<cbc:Information>Veicolo ad esempio: AUTOCARRO</cbc:Information>
<!--Vettore, se diverso da speditore inserirlo. Opzionale. Se usato inserire informazione-->
<cac:CarrierParty>
<cac:PartyName>
<!--Reagione sociale del vettore. Opzionale. Se usato inserire informazione-->
<cbc:Name>Vettore: ad esempio SDA</cbc:Name>
</cac:PartyName>
<!--Informazioni autista. Opzionale. Se usato inserire informazione-->
<cac:Person>
<cac:IdentityDocumentReference>
<!--Informazioni documento Autista. Opzionale. Se usato inserire informazione-->
<cbc:ID>PAT123456</cbc:ID>
<cbc:DocumentType>PATENTE</cbc:DocumentType>
</cac:IdentityDocumentReference>
</cac:Person>
</cac:CarrierParty>
</cac:Consignment>
<!--Gestione Ccnsegna della merce. Opzionale. Se usato inserire informazione-->
<cac:Delivery>
<!--Informazioni sulla consegna della merce. Opzionale. Se usato inserire informazione-->
<cbc:TrackingID>Merce10</cbc:TrackingID>
<!--Periodo stimato sulla consegna della merce. Opzionale. Se usato inserire informazione-->
<cac:EstimatedDeliveryPeriod>
<cbc:StartDate>2015-10-30 </cbc:StartDate>
<cbc:StartTime>08:30:50</cbc:StartTime>
<cbc:EndDate>2015-10-31</cbc:EndDate>
<cbc:EndTime>12:30:50</cbc:EndTime>
</cac:EstimatedDeliveryPeriod>
<!--Evasione della spedizione. Opzionale. Se usato inserire informazione-->
<cac:Despatch>
<!--Periodo e ora evasione spedizione effettiva. Opzionale. Se usato inserire informazione-->
<cbc:ActualDespatchDate>2015-10-31</cbc:ActualDespatchDate>
<cbc:ActualDespatchTime>16:30:30</cbc:ActualDespatchTime>
<!--Informazioni indirizzo evasione spedizione effettiva. Opzionale. Se usato inserire informazione-->
<cac:DespatchAddress>
<cbc:ID>234</cbc:ID>
<cbc:StreetName>Inserire Indirizzo Principale</cbc:StreetName>
<cbc:AdditionalStreetName>Inserire Informazioni Aggiuntive all'Indirizzo</cbc:AdditionalStreetName>
<cbc:CityName>Bologna</cbc:CityName>
<cbc:PostalZone>40100</cbc:PostalZone>
<cbc:CountrySubentity>BO</cbc:CountrySubentity>
<cac:Country>
<cbc:IdentificationCode listID="ISO3166-1:Alpha2">IT</cbc:IdentificationCode>
</cac:Country>
</cac:DespatchAddress>
</cac:Despatch>
</cac:Delivery>
</cac:Shipment>
<!--Tabella prodotti richiesti. Obbligatorio-->
<cac:DespatchLine>
<!--Identificatore di riga. Obbligatorio-->
<cbc:ID>1</cbc:ID>
<!--Note di riga. Opzionale. Se usato inserire informazione-->
<cbc:Note>Inserire Note</cbc:Note>
<!--Unità di misura e quantità consegnata. Obbligatorio-->
<cbc:DeliveredQuantity unitCode="NAR" unitCodeListID="UNECERec20">100</cbc:DeliveredQuantity>
<!--Quantità inevasa. Opzionale. Se usato inserire informazione-->
<cbc:OutstandingQuantity unitCode="NAR" unitCodeListID="UNECERec20">20</cbc:OutstandingQuantity>
<!--Ragione o motivo per la quantità inevasa. Opzionale. Se usato inserire informazione-->
<cbc:OutstandingReason>Inserire Motivazione: Ad esempio Difettosa</cbc:OutstandingReason>
<!--Riferimento a più ordini. Opzionale. Se usato inserire informazione-->
<cac:OrderLineReference>
<!--Riferimento linea d'ordine. Se non valorizzato utilizzare 'NA'. Obbligatorio-->
<cbc:LineID>1</cbc:LineID>
<cac:OrderReference>
<!--Riferimento all'ordine. Obbligatorio-->
<cbc:ID>ORD-2015-321</cbc:ID>
<cbc:IssueDate>2015-10-25</cbc:IssueDate>
<cbc:OrderTypeCode listID="UNCL1001">221</cbc:OrderTypeCode>
</cac:OrderReference>
</cac:OrderLineReference>
<!--Riferimenti aggiuntivi dalle righe dell’avviso spedizione. Opzionale. Se usato inserire informazione-->
<cac:DocumentReference>
<!--Riferimento Linea d'Ordine. Obbligatorio-->
<cbc:ID>45</cbc:ID>
<cbc:IssueDate>2015-09-30</cbc:IssueDate>
<cbc:DocumentType>CIG</cbc:DocumentType>
</cac:DocumentReference>
<!--Riferimenti articolo su riga. Opzionale. Se usato inserire informazione-->
<cac:Item>
<!--Descrizione prodotto. Opzionale, se usato inserire valori-->
<cbc:Name>ABBA 12CPR RIV 875MG 125MG</cbc:Name>
<cbc:AdditionalInformation>Principio Attivo:AMOXICILLINA TRIIDRATA/POTASSIO CLAVULANATO</cbc:AdditionalInformation>
<cac:SellersItemIdentification>
<!--Codice prodotto. Identificatore dell’articolo secondo il Venditore. Obbligatorio-->
<cbc:ID>100123</cbc:ID>
</cac:SellersItemIdentification>
<cac:StandardItemIdentification>
<!--Codice prodotto. Identificatore standard per l’articolo. Obbligatorio.-->
<cbc:ID schemeID="GTIN" schemeAgencyID="9" schemeAgencyName="GS1">036816015</cbc:ID>
</cac:StandardItemIdentification>
<!--Istanza specifica dell’articolo. Opzionale, se usato inserire valori-->
<cac:ItemInstance>
<!--Informazioni specifici dell'articolo. Opzionale, se usato inserire valori-->
<cbc:ManufactureDate>2006-06-23</cbc:ManufactureDate>
<cbc:BestBeforeDate>2020-12-31</cbc:BestBeforeDate>
<cbc:SerialID>ITA00258</cbc:SerialID>
<!--Lotto della merce. Opzionale, se usato inserire valori-->
<cac:LotIdentification>
<cbc:LotNumberID>111222333</cbc:LotNumberID>
<cbc:ExpiryDate>2017-12-31</cbc:ExpiryDate>
</cac:LotIdentification>
</cac:ItemInstance>
</cac:Item>
<!--Informazioni particolari sulla spedizione. Opzionale, se usato inserire valori-->
<cac:Shipment>
<!--Informazioni sulla spedizione. Se non valorizzato utilizzare 'NA'. Opzionale, se usato inserire valori-->
<cbc:ID>NA</cbc:ID>
<cbc:HandlingCode listID="UNCL4079">2</cbc:HandlingCode>
<!--Unità logistica di trasporto. Opzionale, se usato inserire valori-->
<cac:TransportHandlingUnit>
<cbc:ID schemeID="SSCC" schemeAgencyName="GS1">54321</cbc:ID>
<!--Opzionale, se usato inserire valori-->
<cbc:TransportHandlingUnitTypeCode listID="UNECERec21">CT</cbc:TransportHandlingUnitTypeCode>
<cbc:HazardousRiskIndicator>false</cbc:HazardousRiskIndicator>
<cbc:ShippingMarks>FIDIA FARMACEUTICI SpA</cbc:ShippingMarks>
<!--Unità di misura. Opzionale, se usato inserire valori-->
<cac:MeasurementDimension>
<cbc:AttributeID schemeID="UNCL6313">AAB</cbc:AttributeID>
<cbc:Measure unitCode="KGM">50</cbc:Measure>
</cac:MeasurementDimension>
</cac:TransportHandlingUnit>
</cac:Shipment>
</cac:DespatchLine>
<cac:DespatchLine>
<!--Identificatore di riga. Obbligatorio-->
<cbc:ID>2</cbc:ID>
<!--Note di riga. Opzionale. Se usato inserire informazione-->
<cbc:Note>Inserire Note</cbc:Note>
<!--Unità di misura e quantità consegnata. Obbligatorio-->
<cbc:DeliveredQuantity unitCode="NAR" unitCodeListID="UNECERec20">5</cbc:DeliveredQuantity>
<!--Riferimento a più ordini. Opzionale. Se usato inserire informazione-->
<cac:OrderLineReference>
<!--Riferimento linea d'ordine. Se non valorizzato utilizzare 'NA'. Obbligatorio-->
<cbc:LineID>2</cbc:LineID>
<cac:OrderReference>
<!--Riferimento all'ordine. Obbligatorio-->
<cbc:ID>ORD-2015-321</cbc:ID>
<cbc:IssueDate>2015-10-25</cbc:IssueDate>
<cbc:OrderTypeCode listID="UNCL1001">221</cbc:OrderTypeCode>
</cac:OrderReference>
</cac:OrderLineReference>
<!--Riferimenti aggiuntivi dalle righe dell’avviso spedizione. Opzionale. Se usato inserire informazione-->
<cac:DocumentReference>
<!--Riferimento Linea d'Ordine. Obbligatorio-->
<cbc:ID>45</cbc:ID>
<cbc:IssueDate>2015-09-30</cbc:IssueDate>
<cbc:DocumentType>CIG</cbc:DocumentType>
</cac:DocumentReference>
<!--Riferimenti articolo su riga. Opzionale. Se usato inserire informazione-->
<cac:Item>
<!--Descrizione prodotto. Opzionale, se usato inserire valori-->
<cbc:Name>MYLERAN*100CPR RIV 2MG</cbc:Name>
<cbc:AdditionalInformation>Principio Attivo:BUSULFANO</cbc:AdditionalInformation>
<cac:SellersItemIdentification>
<!--Codice prodotto. Identificatore dell’articolo secondo il Venditore. Obbligatorio-->
<cbc:ID>3698233</cbc:ID>
</cac:SellersItemIdentification>
<cac:StandardItemIdentification>
<!--Codice prodotto. Identificatore standard per l’articolo. Obbligatorio.-->
<cbc:ID schemeID="GTIN" schemeAgencyID="9" schemeAgencyName="GS1">024787018</cbc:ID>
</cac:StandardItemIdentification>
<!--Articoli pericolosi. Opzionale, se usato inserire valori-->
<cac:HazardousItem>
<!--Codifiche degli articoli pericolosi. Opzionale, se usato inserire valori-->
<cbc:ID>3249</cbc:ID>
<cbc:UNDGCode listID="UNCL8273">ADR</cbc:UNDGCode>
<cbc:TechnicalName>Medicine, solid, toxic, n.o.s.</cbc:TechnicalName>
<cbc:CategoryName>ANTIBLASTICI</cbc:CategoryName>
<cbc:HazardClassID>6.1</cbc:HazardClassID>
</cac:HazardousItem>
<!--Istanza specifica dell’articolo. Opzionale, se usato inserire valori-->
<cac:ItemInstance>
<!--Informazioni specifici dell'articolo. Opzionale, se usato inserire valori-->
<cbc:ManufactureDate>2010-05-01</cbc:ManufactureDate>
<cbc:BestBeforeDate>2022-12-31</cbc:BestBeforeDate>
<cbc:SerialID>xyz258471</cbc:SerialID>
<!--Lotto della merce. Opzionale, se usato inserire valori-->
<cac:LotIdentification>
<cbc:LotNumberID>12346987777</cbc:LotNumberID>
<cbc:ExpiryDate>2018-12-31</cbc:ExpiryDate>
</cac:LotIdentification>
</cac:ItemInstance>
</cac:Item>
<!--Informazioni particolari sulla spedizione. Opzionale, se usato inserire valori-->
<cac:Shipment>
<!--Informazioni sulla spedizione. Se non valorizzato utilizzare 'NA'. Opzionale, se usato inserire valori-->
<cbc:ID>NA</cbc:ID>
<cbc:HandlingCode listID="UNCL4079">2</cbc:HandlingCode>
<!-- Dettaglio merci sulla temperatura Celsius o Fahrenheit. Opzionale, se usato inserire valori-->
<cac:GoodsItem>
<cac:Temperature>
<cbc:AttributeID>Conservazione</cbc:AttributeID>
<cbc:Measure unitCode="CEL">25</cbc:Measure>
</cac:Temperature>
<cac:MinimumTemperature>
<cbc:AttributeID>Trasporto</cbc:AttributeID>
<cbc:Measure unitCode="CEL">2</cbc:Measure>
</cac:MinimumTemperature>
<cac:MaximumTemperature>
<cbc:AttributeID>Trasporto</cbc:AttributeID>
<cbc:Measure unitCode="CEL">8</cbc:Measure>
</cac:MaximumTemperature>
</cac:GoodsItem>
<!--Unità logistica di trasporto. Opzionale, se usato inserire valori-->
<cac:TransportHandlingUnit>
<cbc:ID schemeID="SSCC" schemeAgencyName="GS1">32569</cbc:ID>
<!--Opzionale, se usato inserire valori-->
<cbc:TransportHandlingUnitTypeCode listID="UNECERec21">CT</cbc:TransportHandlingUnitTypeCode>
<cbc:HazardousRiskIndicator>true</cbc:HazardousRiskIndicator>
<cbc:ShippingMarks>Marca Prodotto</cbc:ShippingMarks>
<!--Unità di misura. Opzionale, se usato inserire valori-->
<cac:MeasurementDimension>
<cbc:AttributeID schemeID="UNCL6313">AAB</cbc:AttributeID>
<cbc:Measure unitCode="KGM">50</cbc:Measure>
</cac:MeasurementDimension>
</cac:TransportHandlingUnit>
</cac:Shipment>
</cac:DespatchLine>
</DespatchAdvice>
This is the XSLT file: UBL2.1_DespatchAdvice.xslt