ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/FeepingCreaturism/Jargon.cpp
Revision: 267
Committed: 2004-10-27T11:18:25-07:00 (20 years, 7 months ago) by Douglas Thrift
File size: 1189 byte(s)
Log Message:
Switched from Sablotron to libxslt after switching from Xalan.

File Contents

# User Rev Content
1 Douglas Thrift 196 // Feeping Creaturism
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Jargon.hpp"
8 Douglas Thrift 224 #include "Matcher.hpp"
9 Douglas Thrift 196
10 Douglas Thrift 230 Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include,
11 Douglas Thrift 267 const ext::String& relative) : include(include)
12 Douglas Thrift 196 {
13 Douglas Thrift 267 args.InsertLast("--stringparam");
14     args.InsertLast("jargon");
15     args.InsertLast(jargon);
16     args.InsertLast("--param");
17     args.InsertLast("include");
18     args.InsertLast(ios::String() << include << "()");
19 Douglas Thrift 225
20     if (!relative.IsEmpty())
21     {
22 Douglas Thrift 267 args.InsertLast("--stringparam");
23     args.InsertLast("relative");
24     args.InsertLast(relative);
25 Douglas Thrift 225 }
26 Douglas Thrift 267
27     args.InsertLast("jargon.xsl");
28     args.InsertLast(ios::String() << path << "/" << jargon);
29 Douglas Thrift 227 }
30 Douglas Thrift 196
31 Douglas Thrift 227 ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
32     {
33 Douglas Thrift 267 _S<api::Process> xslt("/usr/local/bin/xsltproc", jargon.args);
34 Douglas Thrift 196
35 Douglas Thrift 265 if (jargon.include) ios::ReadLine(*xslt.GetReader());
36 Douglas Thrift 224
37 Douglas Thrift 267 if (jargon.include)
38     {
39     ext::String line;
40     Matcher matcher("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$");
41 Douglas Thrift 224
42 Douglas Thrift 267 while (ios::ReadLine(*xslt.GetReader(), line))
43     {
44     while (line == matcher) line = matcher[1] + matcher[2];
45    
46     pout << line << ios::NewLine;
47     }
48     }
49     else ios::ReadToWrite(*xslt.GetReader(), pout);
50    
51 Douglas Thrift 227 return pout;
52 Douglas Thrift 196 }

Properties

Name Value
svn:eol-style native
svn:keywords Id