我是学习<div ng-app="ordinalApp">
<section ng-controller="mainController">
<div ng-repeat="item in items">
{{ ($index + 1) | ordinal }} BF Score
</div>
</section>
</div>
<script>
var app = angular.module("ordinalApp", []);
// what ur looking for
//found here: http: //forums.shopify.com/categories/2/posts/29259
app.filter('ordinal', function($filter) {
var suffixes = ["th", "st", "nd", "rd"];
return function(n) {
var s = ["th", "st", "nd", "rd"],
v = n % 100;
return n + (s[(v - 20) % 10] || s[v] || s[0]);
};
});
app.controller('mainController', function($scope) {
$scope.items = [{
bf_val: 1,
bf_score: 30
}, {
bf_val: 2,
bf_score: 40
}, {
bf_val: 3,
bf_score: 50
}, {
bf_val: 4,
bf_score: 60
}];
});
</script>
的新手。我编写了一个XSD文件和XML文件以及一个针对XSD验证XML的程序。当我运行程序时,我收到错误说明XSD
。有人可以解释一下我的错误。
XSD文件:
Invalid content was found starting with element 'id'. One of '{id}' is expected
XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.edureka.co/Student"
xmlns:st="http://www.edureka.co/Student"
>
<xs:element name="student" type="st:student"></xs:element>
<xs:complexType name="student">
<xs:sequence>
<xs:element name="id" type="xs:int"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="language" type="xs:string"/>
<xs:element name="expertise" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
验证XML文件的Java程序:
<?xml version="1.0" encoding="UTF-8"?>
<student xmlns="http://www.edureka.co/Student"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.edureka.co/Student studentRule.xsd"
>
<id>1234</id>
<name>Pradeep</name>
<language>Sanskrit</language>
<expertise>Beginner</expertise>
</student>
答案 0 :(得分:3)
将属性public class DBConnection
{
#region parameters and properties
IfxConnection connection;
IfxCommand command = new IfxCommand();
IfxTransaction m_current_trans;
IfxDataReader DR;
IfxParameter param;
ConnectionState connectionstate;
string connection_name;
//CONSTANT FOR GENERAL EXCEPTION
int ExCodeConst = -111111;
public enum stmtOrder
{
First = 1,
inBetween = 2,
Last = 3,
}
public IfxConnection Connection
{
get { return connection; }
set { connection = value; }
}
public IfxTransaction current_trans
{
get { return m_current_trans; }
set { m_current_trans = value; }
}
public ConnectionState connectionState
{
get { return connectionstate; }
set { connectionstate = value; }
}
public string ConnectionName
{
get { return connection_name; }
set { connection_name = value; }
}
#endregion
#region Connection Creation and handeling
private void Set_Isolation(bool with_transaction)
{
try
{
Open_Connection();
command = new IfxCommand("SET ISOLATION TO DIRTY READ");
command.Connection = connection;
command.ExecuteNonQuery();
if (!with_transaction)
{
connection.Close();
connectionstate = ConnectionState.Closed;
}
}
catch (Exception ex)
{
ErrMapping.WriteLog(ex.Message);
}
}
private void Open_Connection()
{
try
{
if (connection.State == ConnectionState.Closed)
{
connection.Open();
connectionstate = ConnectionState.Open;
}
}
catch (Exception ex)
{
ErrMapping.WriteLog(ex.Message);
}
}
/// <summary>
/// constructor
/// </summary>
/// <param name="ConnectionName">Connection Name in your application web.config file in ConnectionStrings section </param>
/// <param name="with_transaction">True : if you will use transaction
/// False : if you will not use transaction </param>
public DBConnection(string ConnectionName, bool with_transaction)
{
connection = new IfxConnection(ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString);
this.connection_name = ConfigurationManager.ConnectionStrings[ConnectionName].Name;
command = new IfxCommand();
Set_Isolation(with_transaction);
}
/// <summary>
/// Begin Transaction
/// </summary>
public void Begin_Transaction()
{
if (this.connection.State == ConnectionState.Open)
{
this.current_trans = this.connection.BeginTransaction(IsolationLevel.Serializable);
}
}
/// <summary>
/// Close Connection
/// </summary>
public void Close_Connection()
{
if (connection!= null && connection.State == ConnectionState.Open)
{
connection.Close();
connectionstate = ConnectionState.Closed;
}
}
/// <summary>
/// Destructor
/// </summary>
~DBConnection()
{
Close_Connection();
if(connection!= null)
connection.Dispose();
}
#endregion
}
添加到架构的根元素。
默认为&#34;不合格&#34;,在指定默认命名空间时无法使用。
或者,您可以按原样保留架构,并更新文档以使用非限定格式(没有默认命名空间,只限定全局元素):
elementFormDefault="qualified"
您发布的xml文档位于&#34;合格&#34;格式;每个元素都与命名空间显式关联,您可以通过指定默认值 - <st:student xmlns:st="http://www.edureka.co/Student"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.edureka.co/Student studentRule.xsd"
>
<id>1234</id>
<name>Pradeep</name>
<language>Sanskrit</language>
<expertise>Beginner</expertise>
</st:student>
来实现。
上面的xml在&#34;不合格&#34;格式;必须限定全局元素(即模式中的顶级元素),但是本地元素(即模式中的嵌套元素)必须不合格。在&#34;不合格&#34;格式化本地元素与封闭的全局元素的命名空间隐式关联。
默认名称空间不能用于使用&#34;不合格&#34;的文档中。因为它显式地将没有名称空间前缀的元素与名称空间相关联将其视为关联&#34;空前缀&#34;使用命名空间。
一般来说,&#34;合格&#34;格式是最容易使用的格式。