问题列表 - 第45755页

元素“Root”的命名空间必须来自架构命名空间“http://www.w3.org/2001/XMLSchema”?

我有一个 xml 文档:

<?xml version="1.0" encoding="utf-8"?>
<Root>
  <Child name="MyType" compareMode="EQ"></Child>
</Root>
Run Code Online (Sandbox Code Playgroud)

我想在以下 xsd 的帮助下验证这个 xml:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Child">
          <xs:complexType>
            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:attribute name="compareMode" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

当我尝试验证它时,我收到以下错误:

Exception in thread "main" org.xml.sax.SAXException: Validation failed against correct.xml. ErrorMessage:s4s-elt-schema-ns: The namespace of element 'Root' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
Run Code Online (Sandbox Code Playgroud)

我的问题是为什么Root必须在架构的命名空间中?那可能是我没有正确验证xml文档吗?

公共同步布尔值 isValid(String xmlFragment, File xmlSchema) 抛出 SAXException, IOException{

// …

xml validation xsd saxparseexception

2
推荐指数
1
解决办法
9977
查看次数

Windows XP中的DPI Aware应用程序

我想让我的C#应用​​程序了解DPI.Windows API中有一个名为SetProcessDPIAware()的命令,但问题是它只能在Windows Vista和更高版本的Windows中运行,而不能在XP中运行.如何使控件,按钮和字体DPI识别,使其无论使用何种Windows版本都能正确显示?

windows-xp dpi dpi-aware

2
推荐指数
1
解决办法
3810
查看次数

在交叉发布中,PreviousPage = null

我正在尝试将帖子数据从一个页面传递到下一个页面,但PreviousPage总是等于null.

这就是我在原始页面中的内容(在updatepanel内)

<asp:Button ID="mmGo" runat="server" Text="Merge" PostBackUrl="~/Default2.aspx?action=merge"/>
Run Code Online (Sandbox Code Playgroud)

然后在下一页我有:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ PreviousPageType VirtualPath="~/Default.aspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

...并在.cs文件中:

protected void Page_Load(object sender, EventArgs e)
{
    if (PreviousPage != null)
    {
        string action = Request.QueryString["action"];
        if (action == "merge")
        {
            UpdatePanel SourceControl = (UpdatePanel)PreviousPage.FindControl("UpdatePanel1");
            HiddenField SourceTextBox = (HiddenField)SourceControl.FindControl("txtListIDs");
            if (SourceTextBox != null) …
Run Code Online (Sandbox Code Playgroud)

asp.net

3
推荐指数
1
解决办法
9981
查看次数

确定给定的Python模块是否是内置模块

我正在对各种模块进行一些解析和内省,但我不想解析内置模块.现在,内置模块没有特殊类型,就像有一个types.BuiltinFunctionType,所以我该怎么做?

>>> import CornedBeef
>>> CornedBeef
<module 'CornedBeef' from '/meatish/CornedBeef.pyc'>
>>> CornedBeef.__file__
'/meatish/CornedBeef.pyc'
>>> del CornedBeef.__file__
>>> CornedBeef
<module 'CornedBeef' (built-in)>
Run Code Online (Sandbox Code Playgroud)

根据Python,如果模块没有__file__属性,它显然是内置的.这是否意味着hasattr(SomeModule, '__file__')检查模块是否内置的方法是什么?当然,它并不常见del SomeModule.__file__,但有没有更坚实的方法来确定模块是否内置?

python module internals python-internals

18
推荐指数
2
解决办法
4335
查看次数

默认值Specflow Step Definitions

我开始在SpecFlow的世界里,我遇到了我的第一个问题.在保持我的代码DRY方面,我想做以下事情:

有两种情况:

Given I am on a product page
And myfield equals todays date
Then...

Given I am on a product page
And myfield equals todays date plus 4 days
Then...

我希望使用以下步骤定义来涵盖我的And子句的两个变体:

[Given(@"myfield equals todays date(?: (plus|minus) (\d+) days)?")]
public void MyfieldEqualsTodaysDate(string direction, int? days)
{
//do stuff
}

但是,当SpecFlow尝试解析int时,我一直得到异常?PARAM.我检查了正则表达式,它肯定按预期解析了场景.我知道我可以像方法重载那样粗糙等等,我只是想知道SpecFlow是否支持默认参数值的想法,或者实际上是另一种方法来实现相同的效果.

非常感谢

.net testing bdd specflow

6
推荐指数
1
解决办法
6251
查看次数

为什么TypeSynonymInstances不允许在实例头中使用部分应用的类型同义词?

我知道TypeSynomymInstances只允许在实例头中使用完全应用的类型同义词,但是如果我可以使用paritally应用的类型同义词,它似乎也很方便.

例如:

class Example e where
  thingy :: a -> b -> e a b

-- legit, but awkward
newtype FuncWrapper e a b = FuncWrapper { ap :: a -> e a b }
instance (Example e) => Example (FuncWrapper e) where
  thingy _ = FuncWrapper . flip thingy
funcWrapperUse :: (Example e) => e Int String
funcWrapperUse = thingy 1 "two" `ap` 3 `ap` 4 `ap` 5

-- not legal, but a little easier to use …
Run Code Online (Sandbox Code Playgroud)

haskell

24
推荐指数
2
解决办法
2751
查看次数

具有注释参数的aspectj切入点

我使用aspectj来拦截带注释的方法 @Profile(description="something")

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Profile {
    public String description() default "";
}

@Around("com.merc.aop.ctw.aspect.PointcutDefinitions.logAnnotatedMethods(profile)")
public Object profile(ProceedingJoinPoint pjp, Profile profile) throws Throwable {
    ....
}

@Pointcut("@annotation(com.merc.annotations.Profile)")
protected void logAnnotatedMethods(Profile profile) {
}
Run Code Online (Sandbox Code Playgroud)

但是在使用AJC编译时我得到以下错误消息

formal unbound in pointcut 
Run Code Online (Sandbox Code Playgroud)

aspectj

15
推荐指数
2
解决办法
3万
查看次数

VS2010:代码分析警告CA2000.对象不沿所有异常路径放置

在我制作优秀代码的目标中,我使用"运行代码分析"在Visual Studio 2010中验证了我的项目.在下面的函数中,我得到以下警告,我不明白,因为唯一可以生成异常的行是sqlC.ExecuteNonQuery(),唯一的异常类型是" SQLException ".

CA2000:Microsoft.Reliability:在方法'Company.log(string,string,DateTime,DateTime,string,bool)'中,对象'sqlC'未沿所有异常路径放置.在对对象'sqlC'的所有引用都超出范围之前调用System.IDisposable.Dispose.

为什么分析会抱怨?任何帮助深表感谢!

    private void log(string type, string descr, DateTime start, DateTime end, string msg, bool success)
    {
        SqlCommand sqlC = new SqlCommand();
        sqlC.CommandType = CommandType.Text;
        sqlC.Connection = sc;
        sqlC.CommandText = "INSERT INTO [cap_jobHistoryDetails] (...) VALUES(...)";
        sqlC.Parameters.AddWithValue("@jobID", _job_id.ToString("d", CultureInfo.InvariantCulture));
        sqlC.Parameters.AddWithValue("@type", type);
        sqlC.Parameters.AddWithValue("@start", start);
        sqlC.Parameters.AddWithValue("@end", end);
        sqlC.Parameters.AddWithValue("@descr", descr);
        sqlC.Parameters.AddWithValue("@msg", msg);
        sqlC.Parameters.AddWithValue("@success", (success ? "1" : "0"));

        try
        {
            sqlC.ExecuteNonQuery();
        }
        catch (SqlException)
        {
            sqlC.Dispose();
            throw;
        }
        sqlC.Dispose();
    }
Run Code Online (Sandbox Code Playgroud)

c# visual-studio-2010 .net-3.5

1
推荐指数
1
解决办法
2245
查看次数

UIView,它的超级视图和touchesBegan:

假设我有一个UIViewController子类来处理一些UIViews.这些UIViews被添加为UIViewController view属性的子视图):

UIViewController中:

- (void)viewDidLoad {
    UIImageView *smallImageView...
    [self.view addSubview:smallImageView];

    UIButton *button..
    [self.view addSubview:button];

    UIView *bigUIView.. // covers the entire screen (frame = (0.0, 0.0, 1024.0, 768.0))
    [self.view addSubview:bigUIView];
...
}
Run Code Online (Sandbox Code Playgroud)

AFAIK,因为它bigUIView是最前面的视图并覆盖整个屏幕,它将接收touchesBegan:withEvent:和其他视图,例如button不会接收任何触摸事件.

在我的应用程序中bigUIView必须是最顶层的视图,因为它包含主要的用户界面对象(CALayers,实际上是主要的游戏对象),在动画时,必须位于所有其他辅助UI元素(UIButtons等)之上.但是,我希望能够在响应程序链中保留UIButtons和其他对象.

我尝试在bigUIView课堂上实现以下内容:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {    
    [self.superview touchesBegan:touches withEvent:event];

    ... hit test the touch for this specific uiview..
}
Run Code Online (Sandbox Code Playgroud)

笔记:

  1. bigUIView的superview引用了UIViewController的view属性,它是否将触摸事件传播到它的所有子视图?
  2. bigUIView必须有,userInteractionEnabled = YES因为它也处理用户输入.
  3. 我无法将button/ smallImageView带到前面,因为它会出现在主要游戏对象(子层 …

iphone touch uiview ipad uiresponder

6
推荐指数
1
解决办法
1万
查看次数

如何检查一系列值是否正确排序?

我有很多Action带有财产的物品long Timestamp.我想做这样的事情:

Assert.IsTrue(a1.Timestamp < a2.Timestamp < a3.Timestamp < ... < an.Timestamp);
Run Code Online (Sandbox Code Playgroud)

不幸的是,这种语法是非法的.是否有内置方式或扩展\ LINQ \无论如何执行此操作?

请注意,它是单元测试类的目标,所以要发疯.我不关心性能,可读性等.

.net c# comparison syntactic-sugar

4
推荐指数
1
解决办法
182
查看次数