Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Add meta part to items and remove front requirement #14

Merged
merged 2 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions api/content/item.rng
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@

<sch:ns prefix="libero" uri="http://libero.pub"/>

<include href="parts/front.rng"/>
<include href="parts/meta.rng"/>

<define name="libero.content.item">

<element name="item">
<ref name="libero.content.item.attributes"/>
<oneOrMore>
<ref name="libero.content.item.content"/>
</oneOrMore>
<ref name="libero.content.item.content"/>
</element>

</define>
Expand All @@ -23,7 +21,7 @@
</define>

<define name="libero.content.item.content">
<ref name="libero.content.item.front"/>
<ref name="libero.content.item.meta"/>
</define>

<sch:pattern>
Expand All @@ -37,13 +35,4 @@
</sch:rule>
</sch:pattern>

<sch:pattern>
<sch:rule context="/libero:item/libero:front">
<sch:let name="id" value="libero:id/text()"/>
<sch:assert test="not(preceding-sibling::libero:front[libero:id != $id])">
Found differing IDs: <sch:value-of select="preceding-sibling::libero:front[1]/libero:id/text()"/> and <sch:value-of select="$id"/>
</sch:assert>
</sch:rule>
</sch:pattern>

</grammar>
32 changes: 9 additions & 23 deletions api/content/parts/front.rng
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

<sch:ns prefix="libero" uri="http://libero.pub"/>

<define name="libero.content.item.content" combine="interleave">

<oneOrMore>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oneOrMore because of multiple languages I guess

<ref name="libero.content.item.front"/>
</oneOrMore>

</define>

<define name="libero.content.item.front">

<element name="front">
Expand All @@ -19,29 +27,7 @@
</define>

<define name="libero.content.item.front.content">

<interleave>
<ref name="libero.content.item.front.content.id"/>
<ref name="libero.content.item.front.content.title"/>
</interleave>

</define>

<define name="libero.content.item.front.content.id">

<element name="id">
<ref name="libero.content.item.front.content.id.attributes"/>
<ref name="libero.content.item.front.content.id.content"/>
</element>

</define>

<define name="libero.content.item.front.content.id.attributes">
<empty/>
</define>

<define name="libero.content.item.front.content.id.content">
<ref name="libero.core.types.id"/>
<ref name="libero.content.item.front.content.title"/>
</define>

<define name="libero.content.item.front.content.title">
Expand Down
61 changes: 61 additions & 0 deletions api/content/parts/meta.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>

<grammar ns="http://libero.pub" xmlns="http://relaxng.org/ns/structure/1.0">

<define name="libero.content.item.meta">

<element name="meta">
<ref name="libero.content.item.meta.attributes"/>
<ref name="libero.content.item.meta.content"/>
</element>

</define>

<define name="libero.content.item.meta.attributes">
<empty/>
</define>

<define name="libero.content.item.meta.content">

<interleave>
<ref name="libero.content.item.meta.content.id"/>
<ref name="libero.content.item.meta.content.service"/>
</interleave>

</define>

<define name="libero.content.item.meta.content.id">

<element name="id">
<ref name="libero.content.item.meta.content.id.attributes"/>
<ref name="libero.content.item.meta.content.id.content"/>
</element>

</define>

<define name="libero.content.item.meta.content.id.attributes">
<empty/>
</define>

<define name="libero.content.item.meta.content.id.content">
<ref name="libero.core.types.id"/>
</define>

<define name="libero.content.item.meta.content.service">

<element name="service">
<ref name="libero.content.item.meta.content.service.attributes"/>
<ref name="libero.content.item.meta.content.service.content"/>
</element>

</define>

<define name="libero.content.item.meta.content.service.attributes">
<empty/>
</define>

<define name="libero.content.item.meta.content.service.content">
<ref name="libero.core.types.id"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as

<define name="libero.content.item-ref.attributes.service.content">
<ref name="libero.core.types.id"/>
</define>
but doesn't look right.

</define>

</grammar>
10 changes: 7 additions & 3 deletions tests/api/content/item/extra-content.rng
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@

<define name="libero.content.item.content" combine="interleave">

<element name="content">
<empty/>
</element>
<oneOrMore>
<element name="content">
<optional>
<ref name="libero.core.attributes.lang"/>
</optional>
</element>
</oneOrMore>

</define>

Expand Down
18 changes: 0 additions & 18 deletions tests/api/content/item/invalid/different-ids.xml

This file was deleted.

21 changes: 10 additions & 11 deletions tests/api/content/item/invalid/duplicate.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../basic.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../basic.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?expected-error line="13" message="Duplicate part {http://libero.pub}front@xml:lang='en'" node="/libero:item/libero:front[2]"?>
<?xml-model href="../extra-content.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../extra-content.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?expected-error line="15" message="Duplicate part {http://libero.pub/test}content@xml:lang='en'" node="/libero:item/test:content[2]"?>

<libero:item xmlns:libero="http://libero.pub">
<libero:item xmlns:libero="http://libero.pub" xmlns:test="http://libero.pub/test">

<libero:front xml:lang="en">
<libero:id>1234</libero:id>
<libero:title>Title</libero:title>
</libero:front>
<test:content xml:lang="en"/>

<libero:front xml:lang="en">
<libero:meta>
<libero:id>1234</libero:id>
thewilkybarkid marked this conversation as resolved.
Show resolved Hide resolved
<libero:title>Title</libero:title>
</libero:front>
<libero:service>foo</libero:service>
</libero:meta>

<test:content xml:lang="en"/>

</libero:item>
13 changes: 0 additions & 13 deletions tests/api/content/item/invalid/invalid-content.xml

This file was deleted.

10 changes: 5 additions & 5 deletions tests/api/content/item/invalid/wrong-content.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../basic.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../basic.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?expected-error line="8" message="Did not expect element not-front there"?>
<?expected-error line="8" message="Did not expect element not-meta there"?>

<item xmlns="http://libero.pub">
<not-front xml:lang="en">

<not-meta>
<id>1234</id>
<title>Title</title>
</not-front>
<service>foo</service>
</not-meta>

</item>
6 changes: 3 additions & 3 deletions tests/api/content/item/invalid/wrong-element.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

<not-item xmlns="http://libero.pub">

<front xml:lang="en">
<meta>
<id>1234</id>
<title>Title</title>
</front>
<service>foo</service>
</meta>

</not-item>
3 changes: 1 addition & 2 deletions tests/api/content/item/parts/front/invalid/empty-title.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../basic.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../basic.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?expected-error line="9" message="Title must not be empty" node="/libero:front/libero:title"?>
<?expected-error line="8" message="Title must not be empty" node="/libero:front/libero:title"?>

<libero:front xmlns:libero="http://libero.pub" xml:lang="en">

<libero:id>some-id</libero:id>
<libero:title/>

</libero:front>
6 changes: 6 additions & 0 deletions tests/api/content/item/parts/front/invalid/empty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../basic.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../basic.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?expected-error line="6" message="Expecting an element , got nothing"?>

<front xmlns="http://libero.pub" xml:lang="en"/>
1 change: 0 additions & 1 deletion tests/api/content/item/parts/front/invalid/no-lang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

<front xmlns="http://libero.pub">

<id>some-id</id>
<title>Some Title</title>

</front>
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../basic.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../basic.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?expected-error line="9" message="Title must not be empty" node="/libero:front/libero:title"?>
<?expected-error line="8" message="Title must not be empty" node="/libero:front/libero:title"?>

<libero:front xmlns:libero="http://libero.pub" xml:lang="en">

<libero:id>some-id</libero:id>
<libero:title>

</libero:title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

<back xmlns="http://libero.pub" xml:lang="en">

<id>some-id</id>
<title>Some Title</title>

</back>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<front xmlns="http://libero.pub" xmlns:test="http://libero.pub/test" test:key="value" xml:lang="en">

<id>some-id</id>
<title>Some Title</title>

</front>
1 change: 0 additions & 1 deletion tests/api/content/item/parts/front/valid/extra-content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<front xmlns="http://libero.pub" xmlns:test="http://libero.pub/test" xml:lang="en">

<id>some-id</id>
<test:content/>
<title>Some Title</title>

Expand Down
1 change: 0 additions & 1 deletion tests/api/content/item/parts/front/valid/minimum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<front xmlns="http://libero.pub" xml:lang="en">

<id>some-id</id>
<title>Some Title</title>

</front>
13 changes: 13 additions & 0 deletions tests/api/content/item/parts/meta/basic.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<grammar ns="http://libero.pub/test" xmlns="http://relaxng.org/ns/structure/1.0">

<include href="../../../../../test-case.rng"/>

<include href="../../../../../../api/content/parts/meta.rng"/>

<start>
<ref name="libero.content.item.meta"/>
</start>

</grammar>
21 changes: 21 additions & 0 deletions tests/api/content/item/parts/meta/extra-attribute.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>

<grammar ns="http://libero.pub/test" xmlns="http://relaxng.org/ns/structure/1.0">

<include href="../../../../../test-case.rng"/>

<include href="../../../../../../api/content/parts/meta.rng"/>

<start>
<ref name="libero.content.item.meta"/>
</start>

<define name="libero.content.item.meta.attributes" combine="interleave">

<attribute name="key" ns="http://libero.pub/test">
<text/>
</attribute>

</define>

</grammar>
21 changes: 21 additions & 0 deletions tests/api/content/item/parts/meta/extra-content.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>

<grammar ns="http://libero.pub/test" xmlns="http://relaxng.org/ns/structure/1.0">

<include href="../../../../../test-case.rng"/>

<include href="../../../../../../api/content/parts/meta.rng"/>

<start>
<ref name="libero.content.item.meta"/>
</start>

<define name="libero.content.item.meta.content" combine="interleave">

<element name="content">
<empty/>
</element>

</define>

</grammar>
8 changes: 8 additions & 0 deletions tests/api/content/item/parts/meta/invalid/empty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../basic.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../basic.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?expected-error line="8" message="Expecting an element id, got nothing"?>
<?expected-error line="8" message="Invalid sequence in interleave"?>
<?expected-error line="8" message="Element meta failed to validate content"?>

<meta xmlns="http://libero.pub"/>
Loading