Schema中无顺序的Element的写法

很郁闷的,在网上搜不到相关的内容。
很庆幸,Felix Validate给出很直观的错误提示。

试验了好久,终于写对了,记录一下。

这么写相当于

初等函数

太差劲了,去了上海一个月,回来连初等函数是什么都不知道了。
昨晚自习,在书上看到一切初等函数都是连续的,可是什么是初等函数?
于是回来上网搜了一下:
基本初等函数
我们最常用的有五种基本初等函数,分别是:指数函数、对数函数、幂函数、三角函数及反三角函数。
下面我们用表格来把它们总结一下:

函数名称 函数的记号 函数的图形 函数的性质
指数函数

a):不论x为何值,y总为正数;
b):当x=0时,y=1.

对数函数

a):其图形总位于y轴右侧,并过(1,0)点
b):当a>1时,在区间(0,1)的值为负;在区间(-,+∞)的值为正;在定义域内单调增.

幂函数

a为任意实数


这里只画出部分函数图形的一部分。

令a=m/n
a):当m为偶数n为奇数时,y是偶函数;
b):当m,n都是奇数时,y是奇函数;
c):当m奇n偶时,y在(-∞,0)无意义.

三角函数

(正弦函数)
这里只写出了正弦函数

a):正弦函数是以2π为周期的周期函数
b):正弦函数是奇函数且

反三角函数 (反正弦函数)
这里只写出了反正弦函数

a):由于此函数为多值函数,因此我们此函数值限制在[-π/2,π/2]上,并称其为反正弦函数的主值.

初等函数
由基本初等函数与常数经过有限次的有理运算及有限次的函数复合所产生并且能用一个解析式表出的函数称为初等函数.
例题:
是初等函数。

mod_rewrite: A Beginner’s Guide to URL Rewriting

So you’re a Web developer who has all the bells and whistles on your site, creates Web-based applications that are both beautiful and work well. But what about these issues?

Applications Must Be Safe

A user must not be able to harm your site in any way by modifying a URL that points to your applications. In order to ensure your site’s safe, check all the GET variables coming from your visitors (I think it’s trivial to mention that the POST variables are a must to examine).

For example, imagine we have a simple script that shows all the products in a category.o Generally, it’s called like this:

myapp.php?target=showproducts&categoryid=123

But what will this application do if ScriptKiddie(tm) comes and types this in his browser:

myapp.php?target=showproducts&categoryid=youarebeinghacked

Well, many of the sites I’ve seen will drop some error message complaining about use of the wrong SQL query, invalid MySQL resource ID, and so on… These sites are not secure. And can anyone guarantee that a site-to-be-finished-yesterday will have all the parameter verifications –even in a programmer group having only 2 or 3 people?

Applications Must Be Search-Engine Friendly

It’s not generally known, but many of the search engines will not index your site in depth if it contains links to dynamic pages like the one mentioned above. They simply take the “name” part of the URL (that’s everything before the question mark, which contains the parameters that are needed for most of the scripts to run correctly), and then try to fetch the contents of the page. To make it clear, here are some links from our fictitious page:

myapp.php?target=showproducts&categoryid=123
myapp.php?target=showproducts&categoryid=124
myapp.php?target=showproducts&categoryid=125

Unfortunately, there’s a big chance that some of the search engines will try to download the following page:

myapp.php

In most cases calling a script like this causes an error – but if not, I’m sure it will not show the proper contents the link was pointing to. Just try this search at google.com:

“you have an error in your sql syntax” .php -forum

There are both huge bugs and security in the scripts listed — again, these scripts are not search-engine friendly.

Applications must be user-friendly

If you application uses links like:

http://www.downloadsite.com?category=34769845698752354

then most of your visitors will find it difficult to get back to their favourite category (eg. Nettools/Messengers) every time they start from the main page of your site. Instead, they’d like to see URLs like this:

http://www.downloadsite.com/Nettools/Messengers

It’s even easier for the user to find (pick) the URL from the browsers’ drop-down list as they type into the Location field (though of course this only works if the user has visited that previously).

And what about you?

Now you have everything you need to answer the following questions:

  • Is your site really safe enough?
  • Can you protect your site from hackers?
  • Are your Websites search-engine compatible?
  • Are the URLs on your site ‘user friendly’ – are they easy to remember? …and would you like it to be? (everyone who answered ‘yes’ to all 4 questions: have a beer!)
An elegant solution

Okay, okay, I think you want to know the solution. Well, let’s get started. You’ll need:

  • everyone’s favourite Apache Webserver installed (v1.2 or later)
  • optionally, your favourite CGI scripts configured for Apache. Yes, I’ve said optionally, since what we’re going to do will happen right inside Apache and not PHP, or Perl, etc.
  • since (nearly) everything in Apache is controlled through its configuration files (httpd.conf, .htaccess, etc.), being familiar with these files might help you. You’ll also need to have write access to this file, and access to restart the Apache. I’d strongly recommend you do everything on a private testserver first, rather than on your own, or your company’s, production server!

Most of you will have read and/or heard about mod_rewrite — yes, it’s an Apache module, and it’s even installed by default! Go and check your modules directory (note that under *nix operating systems there’s a chance that your Apache was compiled with missing mod_rewrite, in which case, consult your sysadmin).

We’re going use this tiny module to achieve everything mentioned above. To use this module, first we have to enable it, since it’s initially disabled in the configuration file. Open the httpd.conf file and uncomment the following lines (remove the trailing #s):

#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c

The first line tells Apache to load the mod_rewrite module, while the second one enables the use of it. After you restart Apache, mod_rewrite should be enabled, but not yet running.

What is the mod_rewrite Solution, Exactly?

But what does it exactly do? Hey! Here comes the whole point of this article!

mod_rewrite catches URLs that meet specific conditions, and rewrites them as it was told to.

For example, you can have a non-existing

http://www.mysite.com/anything

URL that is rewritten to:

http://www.mysite.com/deep/stuff/very_complicated_url?text=

having_lots_of_extra_characters

Did you expect something more? Be patient…

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/shortcut$ /complicated/and/way/too/long/url/here
</IfModule>

Of course this, too, should go into the httpd.conf file again, (you can even put it into a virtualhost context).

After you restart Apache (you’ll get used to it soon!) you can type this into your browser:

http://localhost/shortcut

If there’s a directory structure /complicated/and/way/too/long/url/here existing in your document root, you’re going to be “redirected” there, where you’ll see the contents of this directory (eg, the directory listing, index.html, whatever there is).

To understand mod_rewrite better, it’s important to know that this is not true redirection. “Classic” redirection is done with the Location: header of the HTTP protocol, and tells the browser itself to go to another URL. There are numerous ways to do this, for example, in PHP you could write:

<?
// this PHP file is located at http://localhost/shortcut/index.php
header
("Location: /complicated/and/way/too/long/url/here");
?>

This code shows the same page by sending a HTTP header back to the browser. That header tells the browser to move to another URL location instantly. But, what mod_rewrite does is totally different: it ‘tricks’ the browser, and serves the page as if it were really there – that’s why this is an URL rewriter and not a simple redirector (you can even verify the HTTP headers sent and received to understand the difference).

But it’s not just shortening paths that makes mod_rewrite the “Swiss Army Knife of URL manipulation”…

Rules

You’ve just seen how to specify a really simple RewriteRule. Now let’s take a closer look…

RewriteRule Pattern Substitution [Flag(s)]

RewriteRule is a simple instruction that tells mod_rewrite what to do. The magic is that you can use regular expressions in the Pattern and references in the Substitution strings. What do you think of the following rule?

RewriteRule /products/([0-9]+) /siteengine/products.php?id=$1

Now you can use the following syntax in your URLs:

http://localhost/products/123

After restarting Apache, you’ll find this is translated as:

http://localhost/siteengine/products.php?id=123

If you use only ‘fancy’ URLs in your scripts, there will be no way for your visitor to find out where your script resides (/siteengine in the example), what its name is (products.php), or what the name of the parameter to pass (productid) is! Do you like it? We’ve just completed two of our tasks, look!

  • Search-engine compatibility: there are no fancy characters in the URL, so the engines will explore your whole site
  • Security: ScriptKiddie(tm)-modified URLs will cause no error, as they’re verified with the regular expression first to be a number – URLs with no proper syntax can’t even reach the script itself.

Of course, you can create more complex RewriteRules. For example, here’s a set of rules I’m using on a site:

RewriteRule ^/products$ /content.php
RewriteRule ^/products/([0-9]+)$ /content.php?id=$1
RewriteRule
^/products/([0-9]+),([ad]*),([0-9]{0,3}),([0-9]*),([0-9]*$)
/marso/content.php?id=$1&sort=$2&order=$3&start=$4

Thanks to these rules I can use the followings links in the application:

  • Show an opening page that contains product categories: http://somesite.hu/products
  • Product listing, categoryid is 123, page 1 (as default), default order: http://somesite.hu/products/123 http://somesite.hu/products/123,,,,
  • Product listing, categoryid is 123, page 2, descending order by third field (d for descending, 3 for third field): http://somesite.hu/products/123,d,3,2

This is also an example of the use of multiple RewriteRules. When there’s a RegExp match, the proper substitution occurs, mod_rewrite stops running and Apache serves the page with the substituted URL. Should there be no match (after processing all the rules), a usual 404 page comes up. And of course you can also define one or more rules (eg. ^.*$ as last pattern) to specify which script(s) to run depending on the mistaken URL.

The third, optional part of RewriteRule is:

RewriteRule Pattern Substitution Flag(s)

With flags, you can send specific headers to the browser when the URL matches the pattern, such as:

  • forbidden‘ or ‘f‘ for 403 forbidden,
  • gone‘ or ‘g‘ for 410 gone,
  • you may also force redirection, or force a MIME-type.

You can even use the:

  • nocase‘ or ‘NC‘ flag to make the pattern case-insensitive
  • next/N‘ to loop back to the first rule (‘next round‘ — though this may result in an endless loop, be careful with it!)
  • skip=N/'S=N‘ to skip the following N rules

…and so on.

I hope you feel like I felt while playing around with this module for the first time!

Conditions

But that’s not all! Though RewriteRule gives you an opportunity to have professional URL rewriting, you can make it more customized using conditions.

The format of the conditions is simple:

RewriteCond Something_to_test Condition

Any RewriteCond condition affects the behaviour of the following RewriteRule, which is a little confusing, as RewriteCond won’t be evaluated until the following RewriteRule pattern matches the current URL.

It works like this: mod_rewrite takes all the RewriteRules and starts matching the current URL against each RewriteRule pattern. If there’s a RewriteRule pattern that matches the URL, mod_rewrite checks if there are existing conditions for this RewriteRule, and if the first one returns true. If it does, the proper substitution will occur, but if not, mod_rewrite looks for remaining conditions. When there are no more conditions, the subsequent RewriteRule is checked.

This way you can customize URL rewriting using conditions based on practically everything that’s known during a HTTP transfer in Apache — and a lot more! Basically you can use all of these variables in the Something_to_test string:

  • HTTP header variables: HTTP_USER_AGENT, HTTP_REFERER, HTTP_COOKIE, HTTP_FORWARDED, HTTP_HOST, HTTP_PROXY_CONNECTION, HTTP_ACCEPT
  • Connection & request variables: REMOTE_ADDR, REMOTE_HOST, REMOTE_USER, REMOTE_IDENT, REQUEST_METHOD, SCRIPT_FILENAME, PATH_INFO, QUERY_STRING, AUTH_TYPE
  • Server internal variables: DOCUMENT_ROOT, SERVER_ADMIN, SERVER_NAME, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, SERVER_SOFTWARE
  • System variables: TIME_YEAR, TIME_MON, TIME_DAY, TIME_HOUR, TIME_MIN, TIME_SEC, TIME_WDAY, TIME
  • mod_rewrite special values: API_VERSION, THE_REQUEST, REQUEST_URI, REQUEST_FILENAME, IS_SUBREQ

The condition can be a simple string or a standard regular expression, with additions like:

  • <, >, = simple comparison operators
  • -f if Something_to_test is a file
  • -d if Something_to_test is a directory

As you can see, these are more than enough to specify a condition like this one (taken from the mod_rewrite manual):

RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteRule ^/$ /homepage.max.html [L]

RewriteCond %{HTTP_USER_AGENT} ^Lynx.*
RewriteRule ^/$ /homepage.min.html [L]

RewriteRule ^/$ /homepage.std.html [L]

When a browser requests the index page, 3 things can happen:

  • browser with a Mozilla engine the browser will be served homepage.max.html
  • using Lynx (character-based browser) the homepage.min.html will open
  • if the browser’s name doesn’t contain ‘Mozilla’ nor ‘Lynx’, the standard homepage.std.html file will be sent

You can even disable users from accessing images from outside your server:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://localhost/.*$ [OR,NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [OR,NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [OR,NC]
RewriteRule .*\.(gif|GIF|jpg|JPG)$ http://mysite/images/bad.gif [L,R]

But of course, there are endless possibilities, including IP- or time-dependant conditions, etc.

For Advanced Users

I mentioned user-friendliness in the introduction, and haven’t dealt with it. First, let’s imagine we’re having a huge download site that has the downloadable software separated into categories, each with a unique id (which is used in the SQL SELECTs). We use links like open.php?categoryid=23487678 to display the contents of a category.

To ensure that our URLs were easily memorized (eg. http://www.downloadsite.com/Nettools/Messengers) we could use:

RewriteRule ^/NetTools$ /test.php?target=3
RewriteRule ^/NetTools/Messengers$ /test.php?target=34

assuming the ID is 3 for the NetTools category and 34 for Messengers subcategory.

But our site is huge, as I’ve mentioned – who wants to hunt down all the IDs from the database, and then edit the config file by hand? No-one! Instead, we can use the mapping feature of mod_rewrite. Map allows us to provide a replacement-table – stored in a single text file — within a hash file (for fast lookups), or even served through an external program!

For better performance I’d generate a single text file using PHP, which contains the following:

NetTools            3
NetTools/Messengers 34
.
.
.
and so on.

The httpd.conf file would contain:

RewriteMap categories txt:/path/to/file/categoryids.txt
RewriteRule ^(.*)$ open.php?categoryid=${categories:$1|0}

These lines tell mod_rewrite to read the categoryids.txt file upon Apache startup, and provide the ID for the URL for open.php. The |0 means that categoryid will be 0 if there’s no matching key in the textfile.

You can also choose to serve the IDs on-the-fly via a script or other executable code. The program is started by Apache on server startup, and runs until shutdown. The program must have buffered I/O disabled, read from the stdin, and write results to stdout — it’s that simple!

With RewriteMap you can do a lot more, including:

  • load balancing through servers (using rnd:),
  • creation of a Webcluster that has an homogenous URL layout,
  • redirection to mirror sites without modifying your Web application,
  • denial of user access based on a hostlist,

and so on.

Tips, Tricks and Advice
  1. Before using mod_rewrite in a production server, I’d recommend setting up a testserver (or playground, whatever you prefer to call it).
  2. During development, you must avoid using ‘old-fashioned’ URLs in your application.
  3. There might still be need to verify data passed through the URL (passing non-existing — too large or small – IDs, for example, might be risky).
  4. Writing ‘intelligent’ RewriteRules saved me coding time and helped me write simpler code. I’m using error_reporting(E_ALL); everywhere (and I recommend it!), but I find it boring to do the following for the ten thousandths time:if (isset($_GET['id']) && (validNumber($_GET['id']))
    if (isset($_GET['todo']) && ($_GET['todo']=='deleteitem'))

    The following trick helped me to get rid of the extra isset() expression by providing all the needed parameters each time in the RewriteRules:

    RewriteRule ^/products/[0-9]+$ products.php?id=$1&todo=

    I know, I know it’s not the answer to the meaning of life — but it’s hard to show how nice and clear a solution this might provide in such a short example.

Finally…

That’s all for our ‘brief’ overview of mod_rewrite. After you’ve mastered the basics, you’ll find you can easily create your own rules. If you like the idea of URL rewriting, may want to play with mod_rewrite – some ideas follow (note that the underlying PHP code is not important in this case):

http://www.mysite.com/1/2/3/content.html
=> 1_2_3_content.html

http://www.mysite.com/1/2/3/content.html

=> content.php ? category=1

http://www.mysite.com/1/2/3/

=> content.php ? category=1 & subcat1 = 2 & subcat2 = 3

http://www.mysite.com/1/2/3/details

=> content.php ? category=1 & subcat1 = 2 & subcat2 = 3

http://www.mysite.com/bookshop/browse/bytitle

=> library.php ? target=listbooks & order = title

http://www.mysite.com/bookshop/browse/byauthor

=> library.php ? target=listbooks & order = author

http://www.mysite.com/bookshop/product/123

=> library.php ? target=showproduct & itemid=123

http://www.mysite.com/bookshop/helpdesk/2

=> library.php ? target=showhelp & page=2

http://www.mysite.com/bookshop/registration

=> library.php ? target=reg

Links

转自http://www.sitepoint.com/article/guide-url-rewriting/

JavaScript中获取元素的绝对位置

在一些应用中,可能会有需要知道某一个控件在页面中的位置,在网上比较容易找到下面这个解决方法。

在页面中有一个按钮:

在脚本中响应点击事件的是这个函数:

这个方法的实现相当精炼,意思就是先取得自己的相对位置,再叠加其最近的相对位置容器(offsetParent,它不一定是其父节点)的相对位置,直至顶层位置容器(一般就是body),从而得出该节点的相对位置。

不过,很快就发现这个函数也许并不够用,因为我在页面里有可能使用了一些CSS来使得本来平铺的画面变成一个滚动区域,例如设置了父节点的height为 某个值,并且其overflow设为auto或者scroll。这时,上面的方法因为没有计算其滚动偏移,所以所得的值不一定是元素当前的绝对位置,所以 我对上面的方法进行了一些小改动,实际上就是加入了对其滚动偏移量的计算。

稍微测试了一下,基本上在IE和FF中都能正常运转。
在运用方面,由于使用到往上遍历,如果节点树结构过于复杂,而且有不会有滚动出现的话,那么还是用第一个方法就足够了。

.NET Making Gains Against Java, Survey Says

by Stephen Swoyer
30 September 2008

Who’s ahead: Microsoft Corp.’s .NET or Sun Microsystems Inc.’s Java Platform Enterprise Edition (Java EE)?

Five years in and counting, the battle still rages with no clear victor. However, according to a new survey, .NET appears to be widening its lead over Java EE, as the latest revision of the erstwhile Java 2 Enterprise Edition (J2EE) specification is now called. Given the volatility of the .NET/Java EE match-up, that could easily change.

Last year, for example, a survey from development consultancy Evans Data Corp. identified a clear trend in favor of Java development, even though .NET still retained a narrow lead. Thirty-one percent of developers said they planned to tap .NET as their platform of choice for SOA development; 28 percent cited Java.

Evans Data flagged a steep decline in the percentage of developers who expressed a preference for using .NET as a platform for their SOA activities, citing a 20 percent drop in just a six-month period.

This year, the reverse seems to be the case.

According to a new survey from Evans Data, .NET is once again outpacing Java. The survey, which polled 350 developers at enterprise shops with 1,000 or more employees, found that three-fifths (60 percent) of respondents indicated that their .NET investments were growing; fully half said they planned to add additional .NET development personnel.

“These survey results confirm that .NET applications are pervasive in large enterprises and their acceptance and dependability is continuing to increase,” said Mike Allen, director of product management for CA Wily Technology, in a statement. CA Inc. — which markets application performance management (APM) tooling (and which claims that the Evans Data results underscore the importance of effective APM programs) — is a sponsor of the survey.

There might be something to CA’s claims. What’s surprising is how much enterprise IT organizations are spending on their next-gen application architecture investments — particularly for .NET products. More than half of respondents said they’re spending about a quarter of their IT application budgets on .NET development or support, while a staggering one-fifth of respondents say they’re spending between 75 and 100 percent this way.

Also surprising is the non-partisan heterogeneity of today’s enterprise application architectures. Many shops are supporting mixed .NET and Java EE deployments, Evans Data said. A clear majority of respondents said their organizations maintain both .NET and Java groups, for example.

It’s a sign of the times, according to industry veteran Jasmine Noel, a principal with consultancy Ptak, Noel & Associates.

“An increasing number of enterprises are realizing the benefits of deploying applications built on both .NET and Java. However, with those benefits come the challenges of managing a heterogeneous environment coupled with the unique issues of both development architectures,” Noel said in a prepared statement.

Elsewhere, .NET developers are far more likely than Java coders to blame changes — at both the application level and in the back-end — for slowdowns. Java users, on the other hand, disproportionately cite memory leaks and out-of-memory conditions as triggers for application failure.

.NET users were also more likely to cite issues with connectivity to back-end transaction systems, including mainframe systems. Java users, conversely, seem to generate or encounter more bugs. They’re also more likely to find fault with JVM or architecture issues than are .NET users (with the .NET CLR, that is).
You can contact the editors about .NET Making Gains Against Java, Survey Says at editor@reddevnews.com.

开博第一帖

本来在csdn和blogger都有博客的,但终究不是自己的地方,感觉不爽。
现在转移到自己的虚拟主机上,感觉很好,有一种家的感觉,为所欲为的快感。