@@ -132,50 +132,46 @@ private static String getAuthorCreatorXPathInternal(String prologTypeXpath) {
132132 }
133133
134134 /**
135- * Get the XPath of the contributor element with the given author name.
135+ * Get the XPath of the author element with the given type attribute and the given author name.
136136 *
137137 * @param documentType
138138 * The document type( {@link DocumentType#TOPIC},
139139 * {@link DocumentType#MAP}, {@link DocumentType#BOOKMAP}
140140 * or {@link DocumentType#SUBJECT_SCHEME} ).
141+ * @param authorType The type attribute of the author.
141142 * @param authorName The name of the author.
142143 *
143- * @return The XPath of last the creator element.
144+ * @return The XPath of the author element with the given type attribute and the given author name .
144145 */
145- public static String getAuthorContributorXpath (DocumentType documentType , String authorName ) {
146+ public static String getAuthorXpathByTypeAndName (DocumentType documentType , String authorType , String authorName ) {
146147 return documentType .equals (DocumentType .TOPIC )
147- ? getAuthorContributorXPathInternal (ElementXPathConstants .PROLOG_XPATH , authorName )
148- : getAuthorContributorXPathInternal (ElementXPathConstants .TOPICMETA_XPATH , authorName );
148+ ? getAuthorXpathByTypeAndNameInternal (ElementXPathConstants .PROLOG_XPATH , authorType , authorName )
149+ : getAuthorXpathByTypeAndNameInternal (ElementXPathConstants .TOPICMETA_XPATH , authorType , authorName );
149150 }
150151
151152 /**
152- * Get the xpath for retrieving the contributor elements with the given author name.
153+ * Get the XPath of the author element with the given type attribute and the given author name.
153154 *
154155 * @param prologTypeXpath The xpath to prolog/topicmeta element.
155- * @param authorName The name of the author.
156- *
157- * @return The xpath for retrieving all contributor elements with the given author name.
156+ * @param authorType The type attribute of the author.
157+ * @param authorName The name of the author.
158+ *
159+ * @return The XPath of the author element with the given type attribute and the given author name.
158160 */
159- private static String getAuthorContributorXPathInternal (String prologTypeXpath , String authorName ) {
161+ private static String getAuthorXpathByTypeAndNameInternal (String prologTypeXpath , String authorType , String authorName ) {
160162 StringBuilder xpath = new StringBuilder ();
161163 xpath .append (prologTypeXpath );
162- xpath .append ("/author[@type='" );
163-
164- String creatorTypeValue = XmlElementsConstants .CONTRIBUTOR_TYPE ;
165- PluginWorkspace pluginWorkspace = PluginWorkspaceProvider .getPluginWorkspace ();
166- if (pluginWorkspace != null ) {
167- WSOptionsStorage optionsStorage = pluginWorkspace .getOptionsStorage ();
168- String valueFromOptions = optionsStorage .getOption (OptionKeys .CUSTOM_CONTRIBUTOR_TYPE_VALUE , "" );
169- if (!valueFromOptions .isEmpty ()) {
170- creatorTypeValue = valueFromOptions ;
171- }
164+ xpath .append ("/author" );
165+ if (authorType != null ) {
166+ xpath .append ("[@type='" );
167+ xpath .append (authorType ).append ("']" );
168+ }
169+ if (authorName != null ) {
170+ xpath .append ("[text()= '" ).append (authorName ).append ("']" );
172171 }
173- xpath .append (creatorTypeValue );
174- xpath .append ("' and text()= '" ).append (authorName ).append ("']" );
175-
176172 return xpath .toString ();
177173 }
178-
174+
179175 /**
180176 * Get the XPath of the critdates element.
181177 *
0 commit comments