⚲
Project
Profile
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Search
:
Projects
All Projects
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Saxon
Overview
Roadmap
Issues
Calendar
Blog
Documents
Forums
Files
Repository
Download (1.58 KB)
Support #5152
» Program.cs
The code snippet for the validation -
Orlando Ribeiro
, 2021-11-03 12:34
using
System
;
using
System.Diagnostics
;
using
System.IO
;
using
Saxon.Api
;
using
Saxon.Eej.config
;
namespace
ConsoleApp6
{
class
Program
{
static
void
Main
(
string
[]
args
)
{
var
xmlData
=
File
.
ReadAllText
(
@"c:\temp\CIUS\DocExemplo.xml"
);
var
xslData
=
File
.
ReadAllText
(
@"c:\temp\CIUS\urn_feap.gov.pt_CIUS-PT_2.1.1_Full-compiled.xsl"
);
var
data
=
TransformXml
(
xmlData
,
xslData
);
}
public
static
string
TransformXml
(
string
xmlData
,
string
xslData
)
{
EnterpriseConfiguration
conf
=
new
EnterpriseConfiguration
();
conf
.
setConfigurationProperty
(
FeatureKeys
.
LICENSE_FILE_LOCATION
,
@"c:\temp\CIUS\saxon-license.lic"
);
var
xsltProcessor
=
new
Processor
(
conf
);
var
documentBuilder
=
xsltProcessor
.
NewDocumentBuilder
();
documentBuilder
.
BaseUri
=
new
Uri
(
"file://"
);
var
xdmNode
=
documentBuilder
.
Build
(
new
StringReader
(
xmlData
));
var
xsltCompiler
=
xsltProcessor
.
NewXsltCompiler
();
var
xsltExecutable
=
xsltCompiler
.
Compile
(
new
StringReader
(
xslData
));
var
xsltTransformer
=
xsltExecutable
.
Load
();
xsltTransformer
.
InitialContextNode
=
xdmNode
;
xsltTransformer
.
MessageListener
=
new
Action
<
Saxon
.
Api
.
Message
>((
a
)
=>
{
Debug
.
Print
(
a
.
Content
.
ToString
());
});
var
results
=
new
XdmDestination
();
xsltTransformer
.
Run
(
results
);
return
results
.
XdmNode
.
OuterXml
;
}
}
}
« Previous
1
2
3
Next »
(3-3/3)
Loading...