我正在尝试使用C#生成以下xml元素.
<Foo xmlns="http://schemas.foo.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.foo.com
http://schemas.foo.com/Current/xsd/Foo.xsd">
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我得到了异常:前缀"无法从"重新定义到相同的start元素标记内.这是我的c#代码:
XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
XElement foo = new XElement("Foo", new XAttribute("xmlns", "http://schemas.foo.com"),
new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
new XAttribute(xsi + "schemaLocation", "http://schemas.foo.com http://schemas.foo.com/Current/xsd/Foo.xsd"));
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?我正在尝试将生成的xml作为SOAP消息的主体发送,我需要它以接收器的这种格式.
编辑:我在另一个问题上找到了答案.控制XML名称空间的顺序
我试图证明一些关于奇数和偶数自然数的公理.我在我的证明中使用了三种定义的数据类型.
data Nat = Z | S Nat
data Even (a :: Nat) :: * where
ZeroEven :: Even Z
NextEven :: Even n -> Even (S (S n))
data Odd (a :: Nat) :: * where
OneOdd :: Odd (S Z)
NextOdd :: Odd n -> Odd (S (S n))
Run Code Online (Sandbox Code Playgroud)
我还为添加和乘法定义了以下类型系列.
type family Add (n :: Nat) (m :: Nat) :: Nat
type instance Add Z m = m
type instance Add (S n) m = S (Add n …Run Code Online (Sandbox Code Playgroud)