Re: [xsl] CSSXX to XML

Subject: Re: [xsl] CSSXX to XML
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 30 Mar 2013 15:08:40 -0400
Dorothy, I have an example of using unparsed-text() and <xsl:analyze-string> with regular expressions in this publicly-available set of stylesheets that convert CSV (comma-separated values) and TSV (tab-separated values) into XML:

http://www.CraneSoftwrights.com/resources/#csv

The input is a text file and the output is XML. If I were to write what you need I would start with these files myself and work from there.

I hope this helps!

. . . . . . . . . . Ken

At 2013-03-30 15:03 -0400, Dorothy Hoskins wrote:
HI, I have an interesting problem in that I am trying to figure out
how to load and process a CSS file to grab content from CSS class
definitions and poke them into XML files.
In the source XML, which is scraped from XHTML pages, I find images
with CSS classes:
<img class="frame-3" src="image/file.jpeg" alt="image" />

In the CSS of the ePub, I find the dimension information that I want
for the image:
img.frame-3 {
    height:448px;
    width:339px;
}

My desired XML output is <image height="44" width="339"
src="image/file.jpeg" alt="image" />

I have the idea of grabbing the CSS and processing the CSS text to
achieve something like this:
<css>
<class element="img" name="frame-3">
<attribute name="height" value="44"/><!-- px assumed in XHTML -->
<attribute name="width" value="339"/>
</class>
</css>

I know I can handle everything else I want to do once I get the CSS
into an XML structure. The commonalities of the CSS text are that a
line which contains "{" has the information I want for the
class/@element and class/@name. The subsequent lines until the "}"
occurs have the content that I want to process into the attribute/name
and attribute/value. It seems like regex is the way to go but I don't
know how to start - do I load the CSS file into a variable as
xs:string? process it as unparsed-text? if anyone knows a good example
of creating such structure from a text input in the archives or
online, please point me in the right direction.
Thanks, Dorothy


--
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |

Current Thread