Embedding XML data in existing HTML/CSS template - html

I want to embed an XML file into an existing template I have been creating. My website contains a content header, content section, sidebar etc. But I want to embed the XML data into the content section, so that I can use my existing CSS and formatting without rewriting half of it in XSLT. I have already run across the "xml" tag, but I want to import it from an external file rather than inline.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Local fish and chips bar, serving the city for over 20 years.">
<meta name="keywords" content="Food,Drink,Fish,Chips,British">
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<div id="header">
<h1>
<img alt="logo" src="images\logo.jpg" style="width:473px;height:135px">Home</h1>
</div>
<div id = "wrap">
<div id = "navWrap">
<div id = "nav">
<ul>
<li><a class ="nav" href="index.html">Home</a></li>
<li><a class ="nav" href="order.html">Order Online</a></li>
<li><a class ="nav" href="look.html">Look Around</a></li>
<li><a class ="nav" href="contact.html">Contact Us</a></li>
<li><a class ="nav" href="#menu">Download Our Menu</a></li>
<li><a class ="nav" href="#contact">Download Our App</a></li>
<li><a class ="nav" href="report.html">Report</a></li>
</ul>
</div>
</div>
</div>
<div id="main">
<xml Id = msg SRC = "menu.xml"></xml> ----- **XML GOES HERE**
</div>
<div id="sidebar">
<div id = "sidebarMain">
</div>
<div id = "mapWrap">
<iframe src= width="400" height="300" frameborder="0" style="border:0"></iframe>
</div>
<h3><center><u>Opening Times</u></center></h3>
<table style="width:100%">
<tr>
<th>Day</th>
<th>Lunch</th>
<th>Evening</th>
</tr>
<tr>
<td>Monday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Tuesday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Wednesday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Thursday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Friday</td>
<td>10:00 - 14:00</td>
<td>15:00 - 23:00</td>
</tr>
<tr>
<td>Saturday</td>
<td>10:00 - 14:00</td>
<td>15:00 - 23:00</td>
</tr>
<tr>
<td>Sunday</td>
<td>Closed</td>
<td>Closed</td>
</tr>
</table>
</div>
<div id = "footer">
Copyright © FryingNemo.com<br>
<br>
</div>
</body>
</head>
My xml file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="nemoMenu.xsl"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>Light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>Light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>Thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>Two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
Any resolution on the issue would be appreciated, or perhaps I would be better of simply using XSLT.

Neither HTML 4 nor HTML5 has an xml element, only older versions of IE on Windows supported that to embed so called XML data islands inline in HTML. So there is no other way to embed external XML documents in an HTML document other than there is to embed other content, namely the iframe element and the object element. That is as far as static HTML is concerned, of course if you have some server-side programming/processing framework or want to rely on client-side scripting, then there are other options.

Related

Adding parameters from input controls to url in submit action

I am trying to pass parameters from my input text control to the called xquery by adding them as parameters in url. I tried doing in may ways - always without success. Could you have a look and tell me what I am doing wrong?
xquery version "3.0";
declare option exist:serialize "method=xhtml media-type=application/xhtml+xml indent=yes";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";
declare variable $collection as xs:string := '/db/junitReports';
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:bf="http://betterform.sourceforge.net/xforms" xmlns:xf="http://www.w3.org/2002/xforms" bf:toaster-position="tl-down">
<head>
<title>IB interfaces regression testing report</title>
<meta name="author" content="test"/>
<meta name="author" content="test"/>
<meta name="description" content="IB interfaces regression testing report"/>
<link rel="stylesheet" type="text/css" href="styles/demo.css"/>
<!-- INPUT CONTROLS -->
<xf:model>
<xf:instance id="default">
<data xmlns="">
<InterfaceName constraint="true" readonly="false" required="false" relevant="true">
</InterfaceName>
<trigger1 constraint="true" readonly="false" required="false" relevant="true">
</trigger1>
</data>
</xf:instance>
<xf:instance id="table" xmlns="">
<data>
</data>
</xf:instance>
<xf:bind nodeset="InterfaceName" type="string">
</xf:bind>
<xf:submission id="showTable"
method="post"
action="{concat('/exist/rest/db/xquery/returnTable.xq?interface=',InterfaceName)}"
replace="instance"
ref="instance('table')"
instance="table">
</xf:submission>
</xf:model>
</head>
<body class="soria" style="margin:30px;">
<div class="Headline">IB test report</div>
<div class="description">
<p>You can restrict report output:</p>
</div>
<p>2. By typing in particular interface name</p>
<div class="Interface">
<xf:input id="InterfaceName" ref="InterfaceName" incremental="false">
<xf:label></xf:label>
<xf:hint>(S|R)xxxxxYYYZZZ</xf:hint>
<xf:help>Enter interface name</xf:help>
<xf:alert>Enter interface name</xf:alert>
</xf:input>
</div>
<br/>
<div>
<xf:trigger id="trigger1" ref="trigger1" incremental="true">
<xf:label>Filter output</xf:label>
<xf:hint>a Hint for this control</xf:hint>
<xf:help>help for trigger1</xf:help>
<xf:action ev:event="DOMActivate">
<xf:send submission="showTable"/>
</xf:action>
</xf:trigger>
</div>
<div>
<table border="1">
<thead>
<tr>
<th>Inteface Name</th>
<th>Test Date</th>
<th>Test Result</th>
<th>Report Link</th>
</tr>
</thead>
<tbody xf:repeat-nodeset="instance('table')//result">
<tr>
<td>
<xf:output ref="interfaceName"></xf:output>
</td>
<td>
<xf:output ref="reportDate"></xf:output>
</td>
<td>
<xf:output ref="testResult"></xf:output>
</td>
<td>
<li>
<xf:output ref="fileLink"></xf:output>
</li>
</td>
</tr>
</tbody>
</table>
</div>
<label>{InterfaceName}</label>
</body>
</html>
My uri remains without parameters:
"resource-uri":"http://localhost:8080/exist/rest/db/xquery/returnTable.xq?interface="
The right way to do it was to replace action attribute with this element in submission:
<xf:resource value="concat('/exist/rest/db/xquery/returnTable.xq?interface=',instance('defaultInstance')//InterfaceName,'&','date=',instance('defaultInstance')//CalendarDate)"/>

Invalid location of tag (ul) & (table)

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Achievements</title>
</head>
<body>
<h2>수료증 및 수상 내역</h2>
<hr>
<ul>
<h3><li>수료증</li></h3>
<table border="1">
<tr>
<th>과목명</th>
<th>교수명</th>
<th>대학명</th>
</tr>
<tr>
<td>Programming for Everybody(Getting Started with Python)</td>
<td>Charles Severance</td>
<td>University of Michigan</td>
</tr>
</table>
<h3><li>수상내역</li></h3>
<table border="1">
<tr>
<th>대회명</th>
<th>수상일</th>
</tr>
<tr>
<td>The 5th MIRROR Essay Contest</td>
<td>11/23/15</td>
</tr>
</table>
</ul>
<hr>
메인으로
</body>
</html>
I'm using Eclipse Jee Mars btw, and I get warnings saying "Multiple annotations found at this line: Invalid location of tag (h3), Invalid location of tag (h3)" and "Invalid location of (table)". When I open the file through Internet explorer it works fine. What's the problem and how should I fix it?

Fluid Powered TYPO3 FLUX Fluidcontent - No Output in Frontend?

I've made a TYPO3-Installation 6.2.9 with Fluid powered TYPO3 - the first steps with the Pre-configured Distribution "Site" were fine. My Site/Page-Template is installed and I added all the TypoScript stuff.
Now I want to use FLUIDCONTENT (FCE) with FLUX. I've added a new Template-File TeaserOne.html and I try to use the Layout from the Distribution Content.html.
Now I can see and write into my input-fields in Backend, but I've no Output in Frontend?! What else do I need?
I only see the Content-Element Headline. Not the FLEXform.
I'm using the latest Versions of flux (7.1.2), fluidpages (3.1.2), fluidcontent (4.1.1), fluid_core (1.0.2) and vhs (2.1.4).
The static template "fluidcontent_core" was included via pre-configured Distribution.
myext/Resources/Private/Templates/TeaserOne.html
<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
f:schemaLocation="https://fluidtypo3.org/schemas/fluid-master.xsd"
xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers"
flux:schemaLocation="https://fluidtypo3.org/schemas/flux-master.xsd">
<f:layout name="Content" />
<f:section name="Configuration">
<flux:form id="fluidcontenttest" options="{icon: 'Icons/Content/Hello.gif', group: 'New Elements'}">
<flux:field.text name="teasertext" label="hier lorem eintragen" rows="5" cols="30" required="FALSE" />
</flux:form>
</f:section>
<f:section name="Preview">
<table width="100%">
<tr>
<td width="30%">Ausgabe:</td>
<td width="70%">
<f:format.crop maxCharacters="100">{teasertext}</f:format.crop>
</td>
</tr>
</table>
</f:section>
<f:section name="Main">
<h3>TEST: I am a content element! But no Output?</h3>
<p> {teasertext} </p>
</f:section>
</div>
myext/Resources/Private/Layouts/Content.html
<f:layout name="Content" />
<f:render section="Main" />
It seems that the frontend rendering configuration for the CType fluidcontent_content is missing. Did you add the following to your typo3conf/AdditionalConfiguration.php:
<?php
$GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'] = array('fluidcontentcore/Configuration/TypoScript/');

Nokogiri XML to node

I'm reading a local HTML document with Nokogiri like so:
f = File.open(local_xml)
#doc = Nokogiri::XML(f)
f.close
#doc contains a Nokogiri XML object that I can parse using at_css.
I want to modify it using Nokogiri's XML::Node, and I'm absolutely stuck. How do I take this Nokogiri XML document and work with it using node methods?
For example:
#doc.at_css('rates tr').add_next_sibling(element)
returns:
undefined method `add_next_sibling' for nil:NilClass (NoMethodError)
despite the fact that #doc.class is Nokogiri::XML::Document.
For completeness, here is the markup I'm trying to edit.
<html>
<head>
<title>Exchange Rates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table class="rates">
<tr>
<td class="up"><div></div></td>
<td class="date">Saturday, Jan 12</td>
<td class="rate up">3.83</td>
</tr>
<tr>
<td class="up"><div></div></td>
<td class="date">Friday, Jan 11</td>
<td class="rate up">3.70</td>
</tr>
<tr>
<td class="down"><div></div></td>
<td class="date">Thursday, Jan 10</td>
<td class="rate down">3.68</td>
</tr>
<tr>
<td class="down"><div></div></td>
<td class="date">Wedensday, Jan 9</td>
<td class="rate down">3.70</td>
</tr>
<tr>
<td class="up"><div></div></td>
<td class="date">Tuesday, Jan 8</td>
<td class="rate up">3.66</td>
</tr>
</table>
</body>
</html>
This is an example how to do what you are trying to do. Starting with f containing a shortened version of the HTML you want to parse:
require 'nokogiri'
f = '
<html>
<head>
<title>Exchange Rates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table class="rates">
<tr>
<td class="up"><div></div></td>
<td class="date">Saturday, Jan 12</td>
<td class="rate up">3.83</td>
</tr>
</table>
</body>
</html>
'
doc = Nokogiri::HTML(f)
doc.at('.rates tr').add_next_sibling('<p>foobar</p>')
puts doc.to_html
Your code is incorrectly trying to find the class="rates" parameter for <table>. In CSS we'd use .rates. An alternate way to do it using CSS is table[class="rates"].
Your example didn't define the node you were trying to add to the HTML, so I appended <p>foobar</p>. Nokogiri will let you build a node from scratch and append it, or use markup and add that, or you could find a node from one place in the HTML, remove it, and then insert it somewhere else.
That code outputs:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Exchange Rates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table class="rates">
<tr>
<td class="up"><div></div></td>
<td class="date">Saturday, Jan 12</td>
<td class="rate up">3.83</td>
</tr>
<p>foobar</p>
</table>
</body>
</html>
It's not necessary to use at_css or at_xpath instead of at. Nokogiri senses what type of accessor you're using and handles it. The same applies using xpath or css instead of search. Also, at is equivalent to search('some accessor').first, so it finds the first occurrence of the matching node.
Try to load as HTML instead of XML Nokogiri::HTML(f)
Not getting in much detail on how Nokogiri works, lets say that XML does not have css right? So the method at_css doesn't make sense (maybe it does I dunno). So it should work loading as Html.
Update
Just noticed one thing. You want to do at_css('.rates tr') insteand of at_css('rates tr') because that's how you select a class in css. Maybe it works with XML now.

Expected end ASP error

I am not sure how to fix the following error:
Microsoft VBScript compilation error '800a03f6'
Expected 'End'
/junk/test.asp, line 103
else
^
Relevant code:
<%
con.MoveNext()
Wend
%>
</table>
<% else %>
<p>No seminars available.</p>
<%
end if
con.close
%>
Whole code:
<%# LANGUAGE="VBSCRIPT" %>
<%
Dim connectString, connect, conDB, con, src_st
connectString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=" & Server.MapPath("data")
src_st = Request.QueryString("state")
set connect = Server.CreateObject("ADODB.connection")
connect.open connectString
if src_cat = "" then
conDB = "SELECT * FROM travel.csv"
else
conDB = "SELECT * FROM travel.csv where state = ' & src_st & '"
set con = connect.execute(conDB)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Seminars & workshops - AvSafety Seminars</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/screen.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/avsafety.css" />
<link rel="stylesheet" type="text/css" media="handheld" href="/style/handheld.css" />
<link rel="stylesheet" type="text/css" media="print" href="/style/print.css" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<style type="text/css">
<!--
.style2 {color: #666666 }
-->
</style>
<!--
-->
</head>
<body>
<div id="printtitle">Civil Aviation Safety Authority</div>
<div id="outer_wrapper">
<div id="wrapper">
<div id="container">
<div id="title"><h1> </h1></div>
<img src="images/windsock.jpg" alt="" width="166" height="500" align="right" />
<div id="content">
<!--Start of main content area-->
<div id="right"> <img src="/wcmswr/_assets/main/seminars/images/AVSAFETY-LOGO.GIF" alt="AVSafety logo" border="0" width="250px" height="50px">
</div>
<h1>AvSafety Seminars</h1>
<p>CASA is continuing with the Safety Seminar program, targeting pilots in regional Australia and run in partnership with the local aviation industry. </p>
<p>We also hold seminars targeted at engineers.</p>
<p>View further information on safety issues and topics.</p>
<h2>Request a seminar</h2>
<p> If you would like to request an AvSafety seminar in your local town, use the AvSafety request from.</p>
<h2>2013 Seminar schedule</h2>
<p>In 2013 CASA ASAs will be focusing on visiting organisations to discuss the forthcoming aviation regulatory changes. They will be in all regions of Australia and individuals or organisations are welcome to contact their local region ASA to arrange an appointment time. The approximate travel schedule for each region is shown below. ASAs are available and active each month for visits within capital city environs (approximately within 2 hours driving of a capital city).</p>
<p>Aero clubs and other aviation organisation are welcome to run Aviation Safety Seminars with ASAs presenting topics, however CASA will not be financially supporting the events. If you would like to run a seminar with ASA attendance, please use the AvSafety request from and complete the details of the request. Every effort will be made to provide support however it will be advantageous to consider timings when an ASA is visiting a local region.
</p>
<p>ACT | NSW | QLD | SA | TAS | VIC | WA</p>
<table>
<tr>
<th>Location</th>
<th>State</th>
<th>Date</th>
</tr>
<% while (NOT con.EOF) %>
<tr>
<td><%=con("location")%></td>
<td><%=con("state")%></td>
<td><%=con("date")%></td>
</tr>
<%
con.MoveNext()
Wend
%>
</table>
<% else %>
<p>No seminars available.</p>
<%
end if
con.close
%>
<!--End of main content area-->
</div> <!-- content -->
</div> <!-- container -->
<div id="sidebar">
<h2 id = "sidebarhome">CASA home</h2>
<h2>Seminars & workshops</h2>
<ul>
<li>AvSafety Seminars </li>
<li> Maintenance seminars</li>
<li>Archerfield chief pilots</li>
<li>Competency Based Training Education</li>
<li>Manufacturing & certification workshop</li>
</ul>
<form action="http://agencysearch.australia.gov.au/search/search.cgi" name="agencysearch">
<input type="text" name="query" size="13" maxlength="50" value="" alt="Search field" />
<input type="hidden" name="collection" value="agencies" />
<input type="hidden" name="form" value="simple" />
<input type="hidden" name="profile" value="casa" />
<input type="submit" value="Search" name="Search" alt="Search button" />
</form>
</div>
<div class="clearing"> </div>
</div><!-- wrapper -->
</div> <!-- outer_wrapper -->
<div class="extras">
Contact CASA
</div>
<div class="footer">
Site help |
Copyright | Privacy
</div>
</body>
</html>
what if you change your code to this ?
<%
Dim connectString, connect, conDB, con, src_st
connectString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=" & Server.MapPath("data")
src_st = Request.QueryString("state")
set connect = Server.CreateObject("ADODB.connection")
connect.open connectString
if src_cat = "" then
conDB = "SELECT * FROM travel.csv"
else
conDB = "SELECT * FROM travel.csv where state = '" & src_st & "'"
end if
set con = connect.execute(conDB)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Seminars & workshops - AvSafety Seminars</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/screen.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/avsafety.css" />
<link rel="stylesheet" type="text/css" media="handheld" href="/style/handheld.css" />
<link rel="stylesheet" type="text/css" media="print" href="/style/print.css" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<style type="text/css">
<!--
.style2 {color: #666666 }
-->
</style>
<!--
-->
</head>
<body>
<div id="printtitle">Civil Aviation Safety Authority</div>
<div id="outer_wrapper">
<div id="wrapper">
<div id="container">
<div id="title"><h1> </h1></div>
<img src="images/windsock.jpg" alt="" width="166" height="500" align="right" />
<div id="content">
<!--Start of main content area-->
<div id="right"> <img src="/wcmswr/_assets/main/seminars/images/AVSAFETY-LOGO.GIF" alt="AVSafety logo" border="0" width="250px" height="50px">
</div>
<h1>AvSafety Seminars</h1>
<p>CASA is continuing with the Safety Seminar program, targeting pilots in regional Australia and run in partnership with the local aviation industry. </p>
<p>We also hold seminars targeted at engineers.</p>
<p>View further information on safety issues and topics.</p>
<h2>Request a seminar</h2>
<p> If you would like to request an AvSafety seminar in your local town, use the AvSafety request from.</p>
<h2>2013 Seminar schedule</h2>
<p>In 2013 CASA ASAs will be focusing on visiting organisations to discuss the forthcoming aviation regulatory changes. They will be in all regions of Australia and individuals or organisations are welcome to contact their local region ASA to arrange an appointment time. The approximate travel schedule for each region is shown below. ASAs are available and active each month for visits within capital city environs (approximately within 2 hours driving of a capital city).</p>
<p>Aero clubs and other aviation organisation are welcome to run Aviation Safety Seminars with ASAs presenting topics, however CASA will not be financially supporting the events. If you would like to run a seminar with ASA attendance, please use the AvSafety request from and complete the details of the request. Every effort will be made to provide support however it will be advantageous to consider timings when an ASA is visiting a local region.
</p>
<p>ACT | NSW | QLD | SA | TAS | VIC | WA</p>
<table>
<tr>
<th>Location</th>
<th>State</th>
<th>Date</th>
</tr>
<%
if NOT con.eof then
while (NOT con.EOF) %>
<tr>
<td><%=con("location")%></td>
<td><%=con("state")%></td>
<td><%=con("date")%></td>
</tr>
<%
con.MoveNext()
Wend
%>
</table>
<% else %>
<p>No seminars available.</p>
<%
end if
con.close
%>
<!--End of main content area-->
</div> <!-- content -->
</div> <!-- container -->
<div id="sidebar">
<h2 id = "sidebarhome">CASA home</h2>
<h2>Seminars & workshops</h2>
<ul>
<li>AvSafety Seminars </li>
<li> Maintenance seminars</li>
<li>Archerfield chief pilots</li>
<li>Competency Based Training Education</li>
<li>Manufacturing & certification workshop</li>
</ul>
<form action="http://agencysearch.australia.gov.au/search/search.cgi" name="agencysearch">
<input type="text" name="query" size="13" maxlength="50" value="" alt="Search field" />
<input type="hidden" name="collection" value="agencies" />
<input type="hidden" name="form" value="simple" />
<input type="hidden" name="profile" value="casa" />
<input type="submit" value="Search" name="Search" alt="Search button" />
</form>
</div>
<div class="clearing"> </div>
</div><!-- wrapper -->
</div> <!-- outer_wrapper -->
<div class="extras">
Contact CASA
</div>
<div class="footer">
Site help |
Copyright | Privacy
</div>
</body>
</html>