I'm trying to transform a XML file to another XML file. The first file must describe what I want to say in a more abstract way than the second. But in order to do the transformation, I need an intermediate XML file which helps to find that more detailed description needed for the output file.
I was wondering if this could be done using XSLT language. I'm quite new to XML and for what I have read, the XSLT transformation just deals with one input file and another output file.
I would appreciate any kind of help. Thanks in advance.
7 2631
I'm trying to transform a XML file to another XML file. The first file must describe what I want to say in a more abstract way than the second. But in order to do the transformation, I need an intermediate XML file which helps to find that more detailed description needed for the output file.
I was wondering if this could be done using XSLT language. I'm quite new to XML and for what I have read, the XSLT transformation just deals with one input file and another output file.
I would appreciate any kind of help. Thanks in advance.
Try this link: http://www.w3schools.com/xsl/xsl_transformation.asp
Please write if additional help is needed...
Good luck!
Try this as well: http://www.w3schools.com/xsl/xsl_editxml.asp
I searched a little bit more and I found that what I was looking for was something similar to using the function document() in the stylesheet in order to call the external document.
Even so, thank you very much for your advice.
Now a question about the document() function.
I'm trying to do my XSLT transformation on .NET with the XmlCompiledTransform() method. First, it told me that I should change the XsltSettings, because it is not allowed to do the transformation using the document() function on the stylesheet. I changed the settings and now it works. The problem is that I get an error saying that the DTD validation is not enabled for that file (referring to the file accessed with the document function). If I do not write the <!DOCTYPE name SYSTEM "file_name.dtd"> line on the file accessed with the document() function, it works. However, I would like not to erase that line, because I would prefer to do the DTD validation on that file.
Here is my code: -
-
-
try
-
{
-
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
-
xmlReaderSettings.ProhibitDtd = false;
-
-
XmlReader xmlSource = XmlReader.Create("file1.xml", xmlReaderSettings);
-
XPathDocument xpathDoc = new XPathDocument(xmlSource);
-
-
XmlTextReader xslSource = new XmlTextReader("file.xslt");
-
XslCompiledTransform xsltDoc = new XslCompiledTransform();
-
XsltSettings settings = new XsltSettings(true, false);
-
xsltDoc.Load(xslSource,settings, new XmlUrlResolver());
-
-
XmlWriterSettings writerSettings = new XmlWriterSettings();
-
writerSettings.Encoding = System.Text.Encoding.UTF8;
-
writerSettings.OmitXmlDeclaration = false;
-
writerSettings.Indent = true;
-
-
XmlWriter xmlOutput = XmlWriter.Create("file2.xml", writerSettings);
-
-
xmlOutput.WriteDocType("file", null, "file2.dtd", null);
-
-
xsltDoc.Transform(xpathDoc, null, xmlOutput);
-
-
xmlOutput.Close();
-
-
}
-
catch (Exception e)
-
{
-
Console.WriteLine("Excepcion: {0}", e.ToString());
-
}
-
-
Another question:
It seems that the xml:output line I wrote on my stylesheet doesn't work either. That's why I wrote those settings for the output file. Here is that line of the stylesheet: -
-
<xsl:output method="xml" version="1" encoding="utf-8" omit-xml-declaration="no" doctype-system="file2.dtd" indent="yes"/>
-
Thank you for your help.
Does this occur after loading the result xml file or at the end of the transformation?
I don't really understand what you mean, but it occurs when I don't write those settings for the XmlWriter and when I open the file2.xml after the transformation. That file doesn't have the xml declaration and all the other settings. I think that it had to work even if I didn't write those settings because I actually have that line with the xml:output saying the same thing. Thank you very much.
Now a question about the document() function. [HTML]
try
{
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.ProhibitDtd = false;
XmlReader xmlSource = XmlReader.Create("file1.xml", xmlReaderSettings);
XPathDocument xpathDoc = new XPathDocument(xmlSource);
XmlTextReader xslSource = new XmlTextReader("file.xslt");
XslCompiledTransform xsltDoc = new XslCompiledTransform();
XsltSettings settings = new XsltSettings(true, false);
xsltDoc.Load(xslSource,settings, new XmlUrlResolver());
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.Encoding = System.Text.Encoding.UTF8;
writerSettings.OmitXmlDeclaration = false;
writerSettings.Indent = true;
XmlWriter xmlOutput = XmlWriter.Create("file2.xml", writerSettings);
xmlOutput.WriteDocType("file", null, "file2.dtd", null);
xsltDoc.Transform(xpathDoc, null, xmlOutput);
xmlOutput.Close();
}
catch (Exception e)
{
Console.WriteLine("Excepcion: {0}", e.ToString());
} [/HTML]
my stylesheet doesn't work either... [HTML]
<xsl:output method="xml" version="1" encoding="utf-8" omit-xml-declaration="no" doctype-system="file2.dtd" indent="yes"/> [/HTML]
Thank you for your help.
Quite welcome...
I can research this for you, pivote, would be my pleasure, pretty good at researching stuff that nature; not an expert at writing it though, but getting there:-)
In a bit, pivote, and thanks for your patience!
Dököll
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Wolfgang |
last post by:
I'm applying a simple XSLT style sheet to an XML file.
The style sheet is:
http://piru.alexandria.ucsb.edu/~rnott/MetadataMapping/access-report.xsl
The XML file is here:
...
|
by: Jon Martin Solaas |
last post by:
For java programmers there exist a framework called Millstone
(www.millstone.org) for programming web user-interfaces in a component
oriented way. Millstone uses xslt transformations to render...
|
by: gipsy boy |
last post by:
Hello,
I have sort of a big problem. I would really appreciate any help you
could give me.
I made a web service in C++ that throws XML to the client (browser).
But, the XSLT transormation...
|
by: Dan |
last post by:
I have a C# program which executes some XSLT transformations. The XSLT code
requires an input intermediate file, generated by other transformations, as
its duty is copying some data from an input...
|
by: =?Utf-8?B?REZC?= |
last post by:
Within an XSLT transformation, I'm trying to switch the default namespace
within a section of the generated XML document to a shared namespace.
This way, the content of this section does not have...
|
by: Pathik |
last post by:
Hi All,
I am New to xml. Currently I am trying to transform one xml file to
another file using xslt
my xml file is as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet...
|
by: =?Utf-8?B?R2xlbm4gR29tZXo=?= |
last post by:
Does Office Excel 2000 support XSLT transformation of data from XML cause am
having problem when the attachment is opened in the client side if the Excels
version is in Office 2000
and also its...
|
by: groo78 |
last post by:
Hi,
I have an XML document that I need to convert to XHTML and I would like to use XSLT. I have attempted transformations using javascript and it works fine.
The problem I have is that I need...
|
by: boetke |
last post by:
Hi all,
I am attempting to create an xslt transformation which I am having trouble with. I am fairly new to xslt and am having a hard time getting my head around it. The original xml file looks...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shćllîpôpď 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |