2008-11-12 5 views
3

즉시 확인을 위해 rnc 스키마를 사용할 수있는 Emacs의 nxml-mode을 사용하여 XHTML 파일을 편집하고 싶습니다. 이것은 모두 새로운 Emacs 버전에 내장되어 있습니다.RelaxNG (rnc) 스키마가 XHTML을 확장하기 위해

그러나 내 XHTML 파일에는 다른 스키마의 요소가 포함되어 있습니다. 따라서 < foo : foo > 태그는 유효하지만 문서의 < xhtml : head > 내에서만 유효합니다.

현재 nxml은 사용중인 XHTML 스키마가 foo 태그를 설명하지 않기 때문에 불만을 표시합니다. 기존 XHTML 스키마와 관련하여 foo 태그를 설명하는 새로운 스키마를 작성하려면 어떻게해야합니까? schemas.xml 파일에 schema locating rules을 사용하여 해당 스키마를 자동으로 적용하려면 어떻게해야합니까?

예 : 두 개의 스키마 (내장 XHTML 규칙 및 특정 네임 스페이스 태그를 추가하는 사용자 정의 규칙)를 동시에 사용하여 문서의 유효성을 검사하고 싶습니다.

답변

2

Validator.nu은 원래 James Clark이 개발 한 XHTML 스키마 세트에서 수정되었으며 추가 중 하나는 rdf : RDF in head이므로 스키마가 유용 할 수 있습니다. 난 당신이 여기에이 스키마를 원하지 않는다고 생각하지만, 오히려 "포함"한 스키마와 함께, 또 다른 S :

2

문제 (1) (. 나는 nxml 모드 스키마 위치 문제에 경험이 없음) the RelaxNG tutorial의 9.2 절에 설명 된 재정의/조합 규칙 나는 이걸 가지고 씨름하고있다.

문제 2 : 두 번째 문제에 대한 더 나은 답변을 드릴 수 있습니다. nxml-mode는 파일을 스키마와 연관시키기 위해 패턴 일치를 수행하는 "schemas.xml"파일의 여러 위치 중 하나를 찾습니다.

<?xml version='1.0'?> 
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0"> 
    <uri resource="auto.xml" uri="lab.rnc"/> 
</locatingRules> 

이 파일은 "lab.rnc"사양과 "auto.xml"파일을 연관 : 가장 간단한 매핑을 위해, 나는 XML 파일과 같은 디렉토리에이 파일이 있습니다.

2

W3C에는 단지 문제가 있습니다. 예를 들어, 여기에 XHTML + RDFa를위한 RNG입니다 :

<?xml version="1.0" encoding="iso-8859-1"?> 
<!-- XHTML+RDFa 1.0 --> 

<grammar ns="http://www.w3.org/1999/xhtml" 
     xmlns="http://relaxng.org/ns/structure/1.0" 
     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> 

<include href="xhtml-datatypes-1.rng"/> 
<include href="xhtml-attribs-1.rng"/> 
<include href="xhtml-text-1.rng"/> 
<include href="xhtml-list-1.rng"/> 
<include href="xhtml-object-1.rng"/> 
<include href="xhtml-pres-1.rng"/> 
<include href="xhtml-edit-1.rng"/> 
<include href="xhtml-bdo-1.rng"/> 
<include href="xhtml-form-1.rng"/> 
<include href="xhtml-table-1.rng"/> 
<include href="xhtml-image-1.rng"/> 
<include href="xhtml-ssismap-1.rng"/> 
<include href="xhtml-events-1.rng"/> 
<include href="xhtml-inlstyle-1.rng"/> 
<include href="xhtml-base-1.rng"/> 
<include href="xhtml-ruby-1.rng"/> 
<include href="xhtml-metaAttributes-1.rng"/> 

<define name="xhtml.Common.attrib" combine="interleave"> 
    <optional> 
    <attribute name="href"> 
     <ref name="xhtml.URI.datatype"/> 
    </attribute> 
    </optional> 
    <ref name="xhtml.Metainformation.attrib"/> 
</define> 

<include href="xhtml-hypertext-1.rng"> 
    <define name="xhtml.a.attlist"> 
     <ref name="xhtml.Common.attrib"/> 
     <optional> 
     <attribute name="charset"> 
      <ref name="xhtml.Charset.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="type"> 
      <ref name="xhtml.ContentType.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="hreflang"> 
      <ref name="xhtml.LanguageCode.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="accesskey"> 
      <ref name="xhtml.Character.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="tabindex"> 
      <ref name="xhtml.Number.datatype"/> 
     </attribute> 
     </optional> 
    </define> 
</include> 

<include href="xhtml-link-1.rng"> 
    <define name="xhtml.link.attlist"> 
     <ref name="xhtml.Common.attrib"/> 
     <optional> 
     <attribute name="charset"> 
      <ref name="xhtml.Charset.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="hreflang"> 
      <ref name="xhtml.LanguageCode.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="type"> 
      <ref name="xhtml.ContentType.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="media"> 
      <ref name="xhtml.MediaDesc.datatype"/> 
     </attribute> 
     </optional> 
    </define> 
</include> 

<include href="xhtml-meta-1.rng"> 
    <define name="xhtml.meta.attlist"> 
     <ref name="xhtml.Common.attrib"/> 
     <optional> 
     <attribute name="http-equiv"> 
      <data type="NMTOKEN"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="name"> 
      <data type="NMTOKEN"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="scheme"> 
      <text/> 
     </attribute> 
     </optional> 
    </define> 
</include> 

<include href="xhtml-script-1.rng"> 
    <define name="xhtml.script.attlist"> 
     <ref name="xhtml.id.attrib"/> 
     <ref name="xhtml.Metainformation.attrib"/> 
     <optional> 
     <attribute name="href"> 
      <ref name="xhtml.URI.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="charset"> 
      <ref name="xhtml.Charset.datatype"/> 
     </attribute> 
     </optional> 
     <attribute name="type"> 
     <ref name="xhtml.ContentType.datatype"/> 
     </attribute> 
     <optional> 
     <attribute name="src"> 
      <ref name="xhtml.URI.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="defer"> 
      <value>defer</value> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="xml:space"> 
      <value>preserve</value> 
     </attribute> 
     </optional> 
    </define> 
</include> 

<include href="xhtml-style-1.rng"> 
    <define name="xhtml.style.attlist"> 
     <ref name="xhtml.title.attrib"/> 
     <ref name="xhtml.I18n.attrib"/> 
     <ref name="xhtml.id.attrib"/> 
     <ref name="xhtml.Metainformation.attrib"/> 
     <optional> 
     <attribute name="href"> 
      <ref name="xhtml.URI.datatype"/> 
     </attribute> 
     </optional> 
     <attribute name="type"> 
     <ref name="xhtml.ContentType.datatype"/> 
     </attribute> 
     <optional> 
     <attribute name="media"> 
      <ref name="xhtml.MediaDesc.datatype"/> 
     </attribute> 
     </optional> 
     <!-- <optional> 
     <attribute name="xml:space"> 
      <value>preserve</value> 
     </attribute> 
     </optional> --> 
    </define> 
</include> 

<include href="xhtml-csismap-1.rng"> 
    <define name="xhtml.area.attlist"> 
     <ref name="xhtml.Common.attrib"/> 
     <ref name="xhtml.shape.attrib"/> 
     <ref name="xhtml.coords.attrib"/> 
     <optional> 
     <attribute name="nohref"> 
      <value>nohref</value> 
     </attribute> 
     </optional> 
     <attribute name="alt"> 
     <ref name="xhtml.Text.datatype"/> 
     </attribute> 
     <optional> 
     <attribute name="tabindex"> 
      <ref name="xhtml.Number.datatype"/> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="accesskey"> 
      <ref name="xhtml.Character.datatype"/> 
     </attribute> 
     </optional> 
    </define> 
</include> 

<include href="xhtml-param-1.rng"> 
    <define name="xhtml.param.attlist"> 
     <ref name="xhtml.id.attrib"/> 
     <ref name="xhtml.Metainformation.attrib"/> 
     <optional> 
     <attribute name="href"> 
      <ref name="xhtml.URI.datatype"/> 
     </attribute> 
     </optional> 
     <attribute name="name"/> 
     <optional> 
     <attribute name="value"/> 
     </optional> 
     <optional> 
     <attribute name="valuetype"> 
      <choice> 
     <value>data</value> 
     <value>ref</value> 
     <value>object</value> 
      </choice> 
     </attribute> 
     </optional> 
     <optional> 
     <attribute name="type"> 
      <ref name="xhtml.ContentType.datatype"/> 
     </attribute> 
     </optional> 
    </define> 
</include> 

<include href="xhtml-struct-1.rng"> 
    <define name="xhtml.title.attlist"> 
     <ref name="xhtml.Common.attrib"/> 
    </define> 

    <define name="xhtml.head.attlist"> 
     <ref name="xhtml.Common.attrib"/> 
     <ref name="xhtml.profile.attlist"/> 
    </define> 

    <define name="xhtml.html.attlist"> 
     <ref name="xhtml.XHTML.version.attrib"/> 
     <ref name="xhtml.Common.attrib"/> 
    </define> 
</include> 

</grammar> 

언급

관련 문제