Auto add all files in the folder - html

Following part includes a single file but I would like to include all files in the folder which matches with *.log. Is there a way to make it work?
<!DOCTYPE root
[
<!ENTITY log SYSTEM "Log.log">
]>
<root>
&log;
</root>
*.log
There is no root element in log files.
not even <?xml version="1.0" encoding="UTF-8"?> and/or xslt link like <?xml-stylesheet type="text/xsl" href="test.xsl" ?> each file has 1000+ records like below
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<SubType Name="Information">0</SubType>
<Correlation ActivityID="a54221e2-ad37-434a-8f0d-101f7abc2221" />
</System>
<ApplicationData>Test21</ApplicationData>
</E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<SubType Name="Information">0</SubType>
<Correlation ActivityID="d30741c2-da73-434a-8f0d-101f7ceb2228" />
</System>
<ApplicationData>Test24</ApplicationData>
</E2ETraceEvent>

Related

Incorrect display when an image is added to XML

This is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="staff.xsl"?>
<st>
<employee>
<name>
<firstname>Clay</firstname>
<lastname>Hansen</lastname>
</name>
<jobtitle>Professor</jobtitle>
<department>Department: Communication and Marketing</department>
<office>Office: CH-H 111</office>
<phone>Phone: (847)257-1234</phone>
<email>Email: clay.h#abc.com</email>
<profile>
<html xmlns="http://www.w3.org/1999/xhtml">
<img src="C:\Users\username\Desktop\im.jpg" /> <!-- added closing tag by edit -->
</html>
</profile>
</employee>
</st>
here is my xml and extrenal xsl code. When I add an image, it does not display my data in tabular form. It displays it like words in a sentence. How can I solve it?
This is because xsl:value-of returns the concatenated text nodes of a element's subtree with the markup removed (in your case there is none). You could copy the img node like this:
<xsl:for-each select="employee">
<td>
<xsl:copy-of select="profile//xhtml:img"></xsl:copy-of>
</td>
</xsl:for-each>
Note, that you have to declare the xhtml namespace in your stylesheet to process the img nodes:
xmlns:xhtml="http://www.w3.org/1999/xhtml"

xml with xsl different output with links

I want to use my xml file to create different xsl pages.
i.e
<movies>
<movie>
<name>Shark tank</name>
<movie>
<movie>
<name>Tank Shark</name>
<movie>
<movies>
I want to display this information using xsl however i want the first movie on it's on page with a link to another page displaying movie2. Is this possible and if so how do i go about getting my desired outcome ?
On the main page you're going to want something like this at the beginning of the main.xsl file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0" xml:lang="en"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:import href="./file1.xsl"/>
<xsl:import href="./file2.xsl"/>
Unless you are using all xml file with one main xsl file, then add these global variables example after the imports:
<xsl:variable name="MOVIE" select="document('movies.xml')"/>
with that you can call these variables as such:
<a href="http://iheartsharks.com">
<xsl:value-of select="$MOVIE/movie[name = "'Shark tank']"/>
</a>

Using the browser to transform an XML document

I have XML data and am trying to use XSL to format the data. I am following some tutorials. When previewing the XML in Internet Explorer the data is on one line; when previewing with Firefox I get the error message:
Error loading stylesheet: Parsing an XSLT stylesheet failed.
Here the XML:
<?xml version= "1.0"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<countries>
<country>
<countryname>United States</countryname>
</country>
<country>
<countryname>United Kingdom</countryname>
</country>
<country>
<countryname>Deutschland</countryname>
</country>
<country>
<countryname>Osterreich</countryname>
</country>
<country>
<countryname>Espana</countryname>
</country>
<country>
<countryname>France</countryname>
</country>
<country>
<countryname>Italia</countryname>
</country>
<country>
<countryname>China</countryname>
</country>
<country>
<countryname>Hong Kong</countryname>
</country>
<country>
<countryname>Japan</countryname>
</country>
<country>
<countryname>Singapore</countryname>
</country>
<country>
<countryname>Taiwan</countryname>
</country>
<country>
<countryname>Malaysia</countryname>
</country>
</countries>
Here is the XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/countries">
<html>
<body>
<xsl:for-each select="country"
<xsl:value-of select="countryname"/><br/>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylsheet>
Why does the browser not display the XML document as described by the XSL template?
Thank you!
Missing Bracket
<xsl:for-each select="country" must be <xsl:for-each select="country">.
Note the closing >.
Extra Space
Also, you may wish to remove the leading spaces on the first line of the document, if they exist:
<?xml version="1.0" encoding="ISO-8859-1"?>
vs
<?xml version="1.0" encoding="ISO-8859-1"?>
Typo
</xsl:stylsheet> must be </xsl:stylesheet>
After making these changes, the list of countries appear.
Debugging
Consider editing XML and XSL using a text editor that has syntax highlighting and would alert you visually to such errors.

XML's XSLTemplate Shows Up Blank

What am I doing wrong? It shows up as a blank page. I don't know a whole lot of xslt so I'm just testing it right now. If I can't get this to show up though then I can't really test how it works.
My XML
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="q3.xsl"?>
<expenseReport>
<companyInfo>
<name>John Doe</name>
<email>JDoe#company.com</email>
<empNum>1</empNum>
<companyCode>10010011</companyCode>
</companyInfo>
</expenseReport>
xslt
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>Test</h1>
<xsl:value-of select="expenseReport/companyInfo/name"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I can't even get that <h1> to show up, what's going on?
Please use --allow-file-access-from-files if you are trying to view local files from Chrome. They are very strict with local file access so do not rely on this option when you deploy your site. Only use it for development! I just checked it with version 14.0.385.202 and it worked.
Other than this your .xslt is just fine!

XSLT: Transforming into non-xml content?

Is it possible to use XSLT to transform XML into something other than XML?
e.g. i want the final non-xml content:
<Content>
<image url="file1.png">
<image url="file2.png">
...
<image url="filen.png">
<EndContent>
You'll notice this document is not xml (or even html), but it does have what we would call <elements>.
Is it possible, using XSLT, to generate non-xml output?
Another example of non-xml output might be:
<HTML>
<BODY>
<IMG src="file1.png"><BR>
<IMG src="file2.png"><BR>
...
<IMG src="filen.png"><BR>
</BODY>
</HTML>
You'll notice this document is HTML, because in HTML IMG and BR tags are forbidden from having a closing tag. This contrasts with xhtml (the reformulation of HTML using xml) where all elements are required to have a closing tag (because in xml every tag must be closed).
Another example of non-xml output might be:
INSERT INTO Documents (Filename) VALUES ('file1.png')
INSERT INTO Documents (Filename) VALUES ('file2.png')
...
INSERT INTO Documents (Filename) VALUES ('file3.png')
i can make up any source xml i like, but one example might be:
Source xml:
<DocumentStore>
<Document type="image">file1.png</Document>
<Document type="image">file2.png</Document>
<Document type="image">filen.png</Document>
</DocumentStore>
Or perhaps:
<Profiles>
<User avatar="file1.png" />
<User avatar="file2.png" />
<User avatar="filen.png" />
</Profiles>
You can use <xsl:output> to specify the output format, which doesn't have to be xml, see this reference page.
However, if you are outputting html, no modern browser should complain even if you do put the closing tags, so using your example above, i believe all browser should be ok with :-
<HTML>
<BODY>
<IMG src="file1.png"></IMG><BR></BR>
<IMG src="file2.png"></IMG><BR></BR>
...
<IMG src="filen.png"></IMG><BR></BR>
</BODY>
</HTML>
So not too sure why you don't want to put the closing tag, unless i'm missing something.
Update: Added example of non xml output
Given this stylesheet:-
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/filenames">
<xsl:for-each select="filename">
INSERT INTO Documents (Filename) VALUES ('<xsl:value-of select="." />')
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
and this input xml:-
<?xml version="1.0" encoding="UTF-8"?>
<filenames>
<filename>file1.png</filename>
<filename>file2.png</filename>
<filename>file3.png</filename>
</filenames>
You get output like this:-
INSERT INTO Documents (Filename) VALUES ('file1.png')
INSERT INTO Documents (Filename) VALUES ('file2.png')
INSERT INTO Documents (Filename) VALUES ('file3.png')
No matter how you create your IMG tags,
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<HTML>
<BODY>
<xsl:element name="IMG">
<xsl:attribute name="src">file1.png</xsl:attribute>
</xsl:element>
<IMG src="file2.png"></IMG>
<IMG src="filen.png"/>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
The output method "html" will cause the IMG tags to not be closed.
<HTML>
<BODY><IMG src="file1.png"><IMG src="file2.png"><IMG src="filen.png"></BODY>
</HTML>
Yes, you can, by using the xsl:output element in your stylesheet.