I've a requirement to read the content of error.log file within a XSLT. I've tried with document() but I guess it work only for XML files.
Can you please suggest a solution to read the content of error.log file and store it in a variable.
Related
UPDATE: After doing some more poking around, it looks as though the problem has to do with where CF is looking for the DTD file referenced in the XML.
We have the DTDs, but it looks as though CF isn't finding them, so it isn't sure how to parse the XML according to the DTD. I determined this by having it parse XML without any DTD, and it worked as expected and as I wanted - returning a parsed xmlDoc, not a string.
Is there some way of setting the default directory for where CF should look for the DTD specified in the XML?
We're running CF2021, and xmlParse(file), which should return a parsed XML object is instead returning the file contents as a string, inside a wddx encoded object. We have just migrated from a CF2018 server running on a remote hosting service to CF2021 running on an AWS box.
In order to return the XML object we need, I need to run xmlParse on the file, then wddx2cfml on the object, then xmlParse again on the string.
Is there a reason why xmlParse, which should return a parsed XML object, is instead behaving this way?
We pass the system file location to the method. Call it docPath, and it'd look something like g:\appName\xmlFiles\20230125.xml
Then we have, in cfscript:
doc = xmlParse(docPath);
When I dump that to a file, I get what I described above. When I change it to the following, I get what want:
docFile = xmlParse(docPath); cfwddx(action="wddx2cfml", input="#docFile#", output="xmlString"); xmlDoc = xmlParse(xmlString);
But I don't understand why this is necessary, and I'm concerned about having to change it everywhere in the code that we use xmlParse. For the record, this also occurs in tagged CF as well as cfscript, so it's not that.
Putting the dtd files in CF's WEB-INF folder solved the problem. CF was able to match the DTD with the DOCTYPE and properly parse the XML.
I have an existing custom xml file for which I need to add a tag basically append it to the end of root node. But as the xml format will not be changed it can be safely assumed that parsing is not required and only need to add this tag in the end of the file.
XML format:
<links>
...
...
<url type="search">www.google.com</url>
</links>
In the above xml file, I would like to add the tag.
File operation suggests we cannot add in the middle of the file. Can anyone suggest other approaches?
"Safely" is always relative. You can never "safely" assume that you can process XML without parsing unless you are 100% in control of the process that generates the XML, and are confident you will remain so.
And if you are in control of the XML, then I would suggest maintaining it as two files: a content.xml file that holds everything except the root element, and a wrapper.xml file that references content.xml as an external entity:
<!DOCTYPE links [
<!ENTITY e SYSTEM "content.xml">
]>
<links>&e;</links>
and then you can use a normal file append operation on content.xml to add to the content.
I have a "new_xml.xml" file as follows:
<?xml version="1.0" standalone="no"?>
<people>
<husband employed = "Yes">
<name>MArk</name>
<age>45</age>
<wife>
<wname>jenet</wname>
<age>65</age>
</wife>
</husband>
</people>
Now, i want to add following line at the top of "new_xml.xml":
<!DOCTYPE people SYSTEM "new_xmll.dtd">
So, suggest me how can i edit "new_xml.xml" using c++ and add above line into it
You can just open a new file, write the string and the Content of the old file.
ifstream oldXML("path/to/old/xml");
ofstream newXML("path/to/new/xml");
newXML<<"<!DOCTYPE people SYSTEM \"new_xmll.dtd\">"<<endl; //Write first line
newXML<<oldFile; //Copy Content of old file
You can also use a XML library if you want to Change any XML values. I like tinyxml a lot
Then probably TinyXML or MSXML would be interesting for you.
try to use cycle with eof and read each line with getline(), when you find your line just add it.
After creating the xml file with QXmlStreamWriter, I am trying to add each modification of parameters at the end of the file, and I do startDocument in each addition, how can I read an XML file that contains many of
Help please please !
You will have to manually convert the document from your custom format of multiple-concatenated XML files back into real, stand-alone XML files, then pass it into the parser once it is in fact valid XML data.
i have a xsl file which is containing some contents for displaying.This contents gets changed often. so each time have to modify the xsl file.
So thought of moving the content to a text ot properties file so that just changing this will be fine.
can anybody tell me how to move just the contents to a text file and access it using xsl file.
Thanks in advance.
Why use a text file? Surely XML would be better?
An XSLT stylesheet can read a second input document using document('strings.xml'). Then you can access strings as for example
<xsl:value-of select="document('strings.xml')//string[#id='msg012']"/>
where the file has a format like
<strings>
<string id='msg012'>This is one of the strings to include</string>
</strings>
In XSLT 2.0 you can wrap the access logic into a function so the call just becomes
<xsl:value-of select="my:string('msg012')"/>