View Single Post
Old 04-16-2013, 05:45 PM   #7
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by KmC View Post
Would you mind elaborating a bit on the first option? I'm good with JavaScript and using the DOM, but I promise not to do this myself. I will leave the programming to the programmers, but I would at least like to understand it better so as to be as helpful as possible. (and maybe try it myself over lunch)
Well you would have to pick whatever programming language you are most comfortable in program in, and then look for an XML parsing library in that language. (Hopefully I understood what dgatwood was saying).

You would then use this library to go through the XML (perhaps convert it into an array of strings), and from there, step through the array and make any changes as needed.

For example, one pass, you might change all <title> into <span class="title">:

Original:
Code:
<title>TitleofSong</title>
<artist>ArtistofSong</artist>
After "Title" pass:
Code:
<span class="title">TitleofSong</span>
<artist>ArtistofSong</artist>
Then you may have an "Artist" method which will add the paragraph tags, and add a colon between Artist and Title.

After "Artist" pass:
Code:
<p><span class="artist">ArtistofSong</span>: <span class="title">TitleofSong</span></p>
Then a "Body" method might add all the stuff to make it an XHTML file:

Code:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css" />
</head>

<body>
<p><span class="artist">ArtistofSong</span>: <span class="title">TitleofSong</span></p>
</body>
</html>
It is pretty much doing what the XSLT would do, except manually, and in multiple "passes". (If XSLT makes zero sense to you, but you know a programming language well, this is a way to go).

Without having a sample of what XML you are working with, I can only give general (not very helpful in my view) overviews. (Perhaps someone else might be more insightful?)
Tex2002ans is offline   Reply With Quote