My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Web;
using System.Xml;
using System.Net;
using System.Collections;

using Exyus.Xml;
using Exyus.Caching;

namespace Exyus.Web
{
[MediaTypes("text/html")]
public class XmlPageResource : HTTPResource
{
Utility util = new Utility();
Cache ch = new Cache();

string file = string.Empty;
string url = string.Empty;

public string TemplateXml = string.Empty;
public string TemplateXsl = string.Empty;

public XmlPageResource()
{
this.Init();
}
public XmlPageResource(string xml)
{
this.TemplateXml = xml;
this.Init();
}
public XmlPageResource(string xml, string xsl)
{
this.TemplateXml = xml;
this.TemplateXsl = xsl;
this.Init();
}
public XmlPageResource(string xml, string xsl, int age)
{
this.TemplateXml = xml;
this.TemplateXsl = xsl;
this.MaxAge = age;
this.Init();
}

private void Init()
{
if (this.ContentType == null || this.ContentType == string.Empty)
{
this.ContentType = Constants.cType_Html;
}
}

public override void Head()
{
this.Get();
this.Response = null;
}
public override void Get()
{
XmlFileReader xfr = new XmlFileReader();
XmlDocument xmlout = new XmlDocument();
string out_text = string.Empty;

try
{
// return cached copy, if you can
if (ch.CachedResourceIsValid((HTTPResource)this))
return;

// get the document or make one
if (this.TemplateXml != string.Empty)
{
// resolve the xml document and any includes
if (this.TemplateXml.IndexOf("~") != -1)
{
file = Context.Server.MapPath(this.TemplateXml);
}
else
{
file = Context.Server.MapPath(util.GetConfigSectionItem(Constants.cfg_exyusSettings, Constants.cfg_templatefolder) + this.TemplateXml);
}
file = file.Replace("{ftype}", CurrentFileType);

url = this.Context.Request.Url.ToString();
xmlout = xfr.GetXmlFile(file, url);
}
else
xmlout.LoadXml("<root />");

// see if we need to look in the xmlfile for xsldoc
if (this.TemplateXsl == null || this.TemplateXsl == string.Empty && file != string.Empty)
{
this.TemplateXsl = util.GetInlineXslFile(file);
}

// transform results for final output
if (this.TemplateXsl != string.Empty)
{
if (this.TemplateXsl.IndexOf("~") != -1)
{
file = this.Context.Server.MapPath(this.TemplateXsl);
}
else
{
file = this.Context.Server.MapPath(util.GetConfigSectionItem(Constants.cfg_exyusSettings, Constants.cfg_templatefolder) + this.TemplateXsl);
}
file = file.Replace("{ftype}", CurrentFileType);

XslTransformer xslt = new XslTransformer();
out_text = xslt.ExecuteText(xmlout, file, ArgumentList);
}

// handle caching of this resource
ch.CacheResource((HTTPResource)this, util.FixEncoding(out_text));
}
catch (HttpException hex)
{
this.StatusCode = (HttpStatusCode)hex.GetHttpCode();
this.StatusDescription = hex.GetHtmlErrorMessage();
out_text = util.RenderError("http error", hex.GetHtmlErrorMessage(), CurrentMediaType);
}
catch (Exception ex)
{
this.StatusCode = HttpStatusCode.InternalServerError;
this.StatusDescription = ex.Message;
out_text = util.RenderError("unknown error", ex.Message, CurrentMediaType);
}

// return the results
this.Response = util.FixEncoding(out_text);

xmlout = null;
}
}
}
Show details Hide details

Change log

r166 by m...@amundsen.com on Mar 30, 2008   Diff
Other/Utility.cs
  * added GetAllowedMediaTypes
  * add setting X-Acceptable header
  * added signature for ParseUrlPattern
Properties/AssemblyInfo.cs
  * updated to 0.7 version number
  * changed release date
PlainTextViewer.cs
SMTPResource.cs
SqlXmlResource.cs
StaticResource.cs
XmlFileResource.cs
...
Go to: 
Project members, sign in to write a code review

Older revisions

r163 by m...@amundsen.com on Mar 27, 2008   Diff
SMTPResource.cs
  * added use of shared_args
  * updated error rendering
StaticResource.cs
  * added use of arg_list
...
r57 by m...@amundsen.com on Jan 16, 2008   Diff
renamed WebClient.cs to HTTPClient.cs
renamed WebResource.cs to
HTTPResource.cs

made several updates to the samples
...
r39 by m...@amundsen.com on Jan 12, 2008   Diff
Renamed ExyusResource.cs to
WebResource.cs
  * made changes throughout the base
code,
  * updated variable names to reflect
...
All revisions of this file

File info

Size: 4563 bytes, 137 lines

File properties

svn:mime-type
text/plain
svn:eol-style
native
svn:keywords
Id Rev Date Author
Hosted by Google Code