@NotThreadSafe public class PSPattern extends Object implements IPSElement, IPSHasID, IPSHasForeignElements, IPSHasIncludes, IPSHasLets, IPSHasRichGroup
<sch:pattern abstract="true" id="table"> <sch:rule context="$table"> <sch:assert test="$row"> The element <sch:name/> is a table. Tables contain rows. </sch:assert> </sch:rule> <sch:rule context="$row"> <sch:assert test="$entry"> The element <sch:name/> is a table row. Rows contain entries. </sch:assert> </sch:rule> </sch:pattern>When a pattern element has the attribute is-a with a value specifying the name of an abstract pattern, then the pattern is an instance of an abstract pattern. Such a pattern shall not contain any rule elements, but shall have param elements for all parameters used in the abstract pattern.
<sch:pattern is-a="table" id="HTML_Table"> <sch:param name="table" value="table"/> <sch:param name="row" value="tr"/> <sch:param name="entry" value="td|th"/> </sch:pattern> <sch:pattern is-a="table" id="CALS_Table"> <sch:param name="table" value="table"/> <sch:param name="row" value=".//row"/> <sch:param name="entry" value="cell"/> </sch:pattern> <sch:pattern is-a="table" id="calendar"> <sch:param name="table" value="calendar/year"/> <sch:param name="row" value="week"/> <sch:param name="entry" value="day"/> </sch:pattern>When creating an instance of an abstract pattern, the parameter values supplied by the param element replace the parameter references used in the abstract patterns. The examples above use the default query language binding in which the character $ is used as the delimiter for parameter references.
<sch:pattern id="HTML_table"> <sch:rule context="table"> <sch:assert test="tr"> The element table is a table. Tables containing rows. </sch:assert> </sch:rule> <sch:rule context="tr"> <sch:assert test="td|th"> The element tr is a table row. Rows contain entries. </sch:assert> </sch:rule> </sch:pattern> <sch:pattern id="CALS_table"> <sch:rule context="table"> <sch:assert test=".//row"> The element table is a table. Tables containing rows. </sch:assert> </sch:rule> <sch:rule context=".//row"> <sch:assert test="cell"> The element row is a table row. Rows contain entries. </sch:assert> </sch:rule> </sch:pattern> <sch:pattern id="calendar"> <sch:rule context="calendar/year"> <sch:assert test="week"> The element year is a table. Tables containing rows. </sch:assert> </sch:rule> <sch:rule context="week"> <sch:assert test="day"> The element week is a table row. Rows contain entries. </sch:assert> </sch:rule> </sch:pattern>
Constructor and Description |
---|
PSPattern() |
Modifier and Type | Method and Description |
---|---|
void |
addForeignAttribute(String sAttrName,
String sAttrValue) |
void |
addForeignElement(com.helger.xml.microdom.IMicroElement aForeignElement) |
void |
addInclude(PSInclude aInclude)
Add an include to this object.
|
void |
addLet(PSLet aLet)
Add a
PSLet element. |
void |
addP(PSP aP) |
void |
addParam(PSParam aParam) |
void |
addRule(PSRule aRule) |
com.helger.commons.collection.ext.ICommonsList<IPSElement> |
getAllContentElements() |
com.helger.commons.collection.ext.ICommonsOrderedMap<String,String> |
getAllForeignAttributes() |
com.helger.commons.collection.ext.ICommonsList<com.helger.xml.microdom.IMicroElement> |
getAllForeignElements() |
com.helger.commons.collection.ext.ICommonsList<PSInclude> |
getAllIncludes() |
com.helger.commons.collection.ext.ICommonsList<PSLet> |
getAllLets() |
com.helger.commons.collection.ext.ICommonsOrderedMap<String,String> |
getAllLetsAsMap() |
com.helger.commons.collection.ext.ICommonsList<PSParam> |
getAllParams() |
com.helger.commons.collection.ext.ICommonsList<PSP> |
getAllPs() |
com.helger.commons.collection.ext.ICommonsList<PSRule> |
getAllRules() |
com.helger.xml.microdom.IMicroElement |
getAsMicroElement() |
String |
getID() |
String |
getIsA() |
PSRichGroup |
getRich() |
int |
getRuleCount() |
PSRule |
getRuleOfID(String sID) |
PSTitle |
getTitle() |
boolean |
hasAnyInclude() |
boolean |
hasAnyLet() |
boolean |
hasAnyParam() |
boolean |
hasForeignAttributes() |
boolean |
hasForeignElements() |
boolean |
hasTitle() |
boolean |
isAbstract() |
boolean |
isMinimal() |
boolean |
isValid(IPSErrorHandler aErrorHandler)
Check if this element is specified completely.
|
void |
setAbstract(boolean bAbstract) |
void |
setID(String sID)
Set an ID for this object.
|
void |
setIsA(String sIsA) |
void |
setRich(PSRichGroup aRich)
Overwrite any existing rich group.
|
void |
setTitle(PSTitle aTitle) |
String |
toString() |
void |
validateCompletely(IPSErrorHandler aErrorHandler)
Check if this element is specified completely.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addForeignElements
addForeignAttributes
getRichClone, hasRich
public boolean isValid(@Nonnull IPSErrorHandler aErrorHandler)
IPSElement
isValid
in interface IPSElement
aErrorHandler
- The error handler where the error details are stored. May not be
null
.true
if all mandatory fields are set and the element
is valid, false
otherwise.public void validateCompletely(@Nonnull IPSErrorHandler aErrorHandler)
IPSElement
validateCompletely
in interface IPSElement
aErrorHandler
- The error handler where the error details are stored. May not be
null
.public boolean isMinimal()
isMinimal
in interface IPSElement
true
if this element conforms to the Schematron
minimal syntax, false
otherwise.public void addForeignElement(@Nonnull com.helger.xml.microdom.IMicroElement aForeignElement)
addForeignElement
in interface IPSHasForeignElements
public boolean hasForeignElements()
hasForeignElements
in interface IPSHasForeignElements
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<com.helger.xml.microdom.IMicroElement> getAllForeignElements()
getAllForeignElements
in interface IPSHasForeignElements
public void addForeignAttribute(@Nonnull String sAttrName, @Nonnull String sAttrValue)
addForeignAttribute
in interface IPSHasForeignAttributes
public boolean hasForeignAttributes()
hasForeignAttributes
in interface IPSHasForeignAttributes
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsOrderedMap<String,String> getAllForeignAttributes()
getAllForeignAttributes
in interface IPSHasForeignAttributes
public void setAbstract(boolean bAbstract)
public boolean isAbstract()
public void setID(@Nullable String sID)
IPSHasID
public void setRich(@Nullable PSRichGroup aRich)
IPSHasRichGroup
setRich
in interface IPSHasRichGroup
aRich
- The new rich group to set. May be null
.@Nullable public PSRichGroup getRich()
getRich
in interface IPSHasRichGroup
null
if none is
present.public void addInclude(@Nonnull PSInclude aInclude)
IPSHasIncludes
addInclude
in interface IPSHasIncludes
aInclude
- The include to be added. May not be null
.public boolean hasAnyInclude()
hasAnyInclude
in interface IPSHasIncludes
true
if at least one include is present in this
object.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<PSInclude> getAllIncludes()
getAllIncludes
in interface IPSHasIncludes
null
.public boolean hasTitle()
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<PSRule> getAllRules()
@Nonnegative public int getRuleCount()
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<PSParam> getAllParams()
public boolean hasAnyParam()
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<PSP> getAllPs()
public void addLet(@Nonnull PSLet aLet)
IPSHasLets
PSLet
element.addLet
in interface IPSHasLets
aLet
- The let element to be added. May not be null
.public boolean hasAnyLet()
hasAnyLet
in interface IPSHasLets
true
if this object has at least on contained
PSLet
object.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<PSLet> getAllLets()
getAllLets
in interface IPSHasLets
PSLet
elements. Never
null
.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsOrderedMap<String,String> getAllLetsAsMap()
getAllLetsAsMap
in interface IPSHasLets
PSLet
elements as an ordered Map from
name to value. The order must match the declaration order! Never
null
.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<IPSElement> getAllContentElements()
@Nonnull public com.helger.xml.microdom.IMicroElement getAsMicroElement()
getAsMicroElement
in interface IPSElement
null
.Copyright © 2014–2016 Philip Helger. All rights reserved.