如果我通过xmllint运行此XML验证:
xmllint --noout --schema schema.xsd test.xml
Run Code Online (Sandbox Code Playgroud)
我收到了这条成功的消息:
.../test.xml validates
Run Code Online (Sandbox Code Playgroud)
但是,如果我通过libxml2的C API运行相同的验证:
int result = xmlSchemaValidateDoc(...)
Run Code Online (Sandbox Code Playgroud)
我得到一个返回值1845和此失败消息:
Element '{http://example.com/XMLSchema/1.0}foo': No matching global declaration available for the validation root.
Run Code Online (Sandbox Code Playgroud)
我绝对没有意义.:(
schema.xsd:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" >
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/XMLSchema/1.0" targetNamespace="http://example.com/XMLSchema/1.0" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="foo">
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
的test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="http://example.com/XMLSchema/1.0">
</foo>
Run Code Online (Sandbox Code Playgroud)
main.c中:
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h> …Run Code Online (Sandbox Code Playgroud) 因此,我想使用libav 在特定时间从视频中抓取一个帧作为缩略图使用.
我正在使用的是以下代码.它编译和工作正常(关于检索图片),但我很难找到它来检索正确的图片.
我根本无法理解libav明显使用每个视频的多个时基背后的明确逻辑.具体说明哪些函数期望/返回哪种类型的时基.
不幸的是,文档基本上没有任何帮助.那么救援?
#define ABORT(x) do {fprintf(stderr, x); exit(1);} while(0)
av_register_all();
AVFormatContext *format_context = ...;
AVCodec *codec = ...;
AVStream *stream = ...;
AVCodecContext *codec_context = ...;
int stream_index = ...;
// open codec_context, etc.
AVRational stream_time_base = stream->time_base;
AVRational codec_time_base = codec_context->time_base;
printf("stream_time_base: %d / %d = %.5f\n", stream_time_base.num, stream_time_base.den, av_q2d(stream_time_base));
printf("codec_time_base: %d / %d = %.5f\n\n", codec_time_base.num, codec_time_base.den, av_q2d(codec_time_base));
AVFrame *frame = avcodec_alloc_frame();
printf("duration: %lld @ %d/sec (%.2f sec)\n", …Run Code Online (Sandbox Code Playgroud) 我几乎没有看到第二个用过,我想知道为什么?
NSArray预期的情况的支持(因为它是一个子类).在前提条件下,它永远不会是一个可变的ivar返回,(无论如何应该是常识)
我现在只能想到使用第二个的优点.
[[[foo fooBar] mutableCopy] autorelease],不必要地分配额外的内存,不必要地浪费时间.以下是方法变体:
- (NSArray *)fooBar {
NSMutableArray *fooArray = [NSMutableArray array];
//populate fooArray
return fooArray;
}
- (NSMutableArray *)fooBar {
NSMutableArray *fooArray = [NSMutableArray array];
//populate fooArray
return fooArray;
}
Run Code Online (Sandbox Code Playgroud)
我问,因为我的项目有一堆具有相同模式的方法.
并且在大多数情况下,返回的数组将在之后被修改(合并,编辑等).
所以我认为返回应该是完全没问题NSMutableArrays,但似乎没有人这样做.
NSMutableArray,NSMutableSet …