forked from citation-style-language/schema
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new cs:conditions element to choose (citation-style-language#260)
This adds a modified version of the CSL-M conditions element and condition child as an option to configure more complex conditional rules. Also splits off the cs:choose section into a separate file. Closes citation-style-language#255
- Loading branch information
Showing
2 changed files
with
86 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" | ||
namespace cs = "http://purl.org/net/xbiblio/csl" | ||
|
||
|
||
## cs:choose - Conditional Statements" | ||
div { | ||
rendering-element.choose = | ||
|
||
## Use to conditionally render rendering elements. | ||
element cs:choose { choose.if, choose.else-if*, choose.else? } | ||
|
||
## When specifying conditions, we allow either the attribute syntax or the element-based one. | ||
choose.condition = | ||
condition.atts | ||
| element cs:conditions { match, condition.elem+ } | ||
choose.if = element cs:if { choose.condition, rendering-element* } | ||
choose.else-if = | ||
element cs:else-if { choose.condition+, rendering-element* } | ||
choose.else = element cs:else { rendering-element+ } | ||
|
||
## This element allows for more complex conditional logic; for | ||
## example, if you need to specify mixed "match" rules. | ||
condition.elem = element cs:condition { match?, condition.atts } | ||
condition.atts = | ||
|
||
## If used, the element content is only rendered if it disambiguates two | ||
## otherwise identical citations. This attempt at disambiguation is only | ||
## made after all other disambiguation methods have failed. | ||
[ a:defaultValue = "true" ] attribute disambiguate { "true" } | ||
| | ||
## Tests whether the given variables contain numeric text. | ||
attribute is-numeric { | ||
list { variables+ } | ||
} | ||
| | ||
## Tests whether the given date variables contain approximate dates. | ||
attribute is-uncertain-date { | ||
list { variables.dates+ } | ||
} | ||
| | ||
## Tests whether the locator matches the given locator types. | ||
attribute locator { | ||
list { (terms.locator.testable | "sub-verbo")+ } | ||
} | ||
| | ||
## Tests whether the cite position matches the given positions. | ||
attribute position { | ||
list { | ||
("first" | ||
| "subsequent" | ||
| "ibid" | ||
| "ibid-with-locator" | ||
| "near-note")+ | ||
} | ||
} | ||
| | ||
## Tests whether the item matches the given types. | ||
attribute type { | ||
list { item-types+ } | ||
} | ||
| | ||
## Tests whether the default ("long") forms of the given variables | ||
## contain non-empty values. | ||
attribute variable { | ||
list { variables+ } | ||
} | ||
match = | ||
|
||
## Set the testing logic. | ||
[ a:defaultValue = "all" ] | ||
attribute match { | ||
|
||
## Element only tests "true" when all conditions test "true" for all | ||
## given test values. | ||
"all" | ||
| | ||
## Element tests "true" when any condition tests "true" for any given | ||
## test value. | ||
"any" | ||
| | ||
## Element only tests "true" when none of the conditions test "true" | ||
## for any given test value. | ||
"none" | ||
}? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters