cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Using the bookpartno field on my manual cover

bfriesen
17-Peridot

Using the bookpartno field on my manual cover

I am wanting to use the bookpartno field from my ditamap on the cover of my manual. Currently I have two being used. How do I write the new one so it will choose the one in the middle?


/RDStyle/ResolvedMap/servicemanualmap/*[name()='bookmeta' or name()='servicemanualmeta']/bookid/bookpartno[last()]



Bryon

4 REPLIES 4

Hi Bryon—

It depends how constrained the structure is. If you know the ordinal number of the one you want, you can just use that as the predicate in your XPath. For example, if you know you always want the second one, you can use something like this:

/RDStyle/ResolvedMap/servicemanualmap/*[name()='bookmeta' or name()='servicemanualmeta']/bookid/bookpartno[2]

If you can’t say for sure it will always be in the same position, then you will have to come up with some kind of rule that will give you the one you want.

Your description as “the one in the middle” implies that there are always exactly 3 items, and you want the second one. For that, the expression above would suffice. But if you might have instances where there are 4 or 5 items, then how would you decide which of the multiple middle ones you want? If you could sometimes have only two, and you wouldn’t want the second one in that case, what would you want to do in that situation?

--Clay
bfriesen
17-Peridot
(To:bfriesen)

Thanks for the response Clay. We are using the first one for the book part no, the second one will be used for the dollar value of the manual and the third will be used for the publication year. From your example I would expect that as long we have defined a first and last, the numbering would be sequencal after that.


/RDStyle/ResolvedMap/servicemanualmap/*[name()='bookmeta' or name()='servicemanualmeta']/bookid/bookpartno[2]


/RDStyle/ResolvedMap/servicemanualmap/*[name()='bookmeta' or name()='servicemanualmeta']/bookid/bookpartno[3]


I see your point if one is left blank then the next one steps up and is the next number. I guess we would need to add a space so something would be there.


Thanks


Bryon

bfriesen
17-Peridot
(To:bfriesen)

Hi Bryon—



Ah, OK. In that case, you should be able to use simple position predicates, as long as you always have the right number of bookpartno elements, including empty ones if no value is specified.



OTOH, as you describe the intended uses for these extra bookpartno elements, I wonder if maybe there would be other bookmeta markup elements better suited to those items. For example, publication year might be better stored as bookmeta/publisherinformation/published/completed (or, if it’s really a proxy for copyright date, as bookmeta/bookrights/copyyrlast).



Or, of course, for items that aren’t defined explicitly in standard DITA book metadata, you could use othermeta to avoid any ambiguity, something like this:



<bookmeta>


….


<othermeta name="”bookprice”" content="”$40.00”/">


<othermeta name="”publicationdate”" content="”2015”/">


</bookmeta>



I understand the occasional need to shoehorn some unusual data into a structure that wasn’t originally designed for it, but in this case, since DITA comes OOTB with a generic metadata mechanism, why not use it instead of overloading <bookpartno>?



--Clay

bfriesen
17-Peridot
(To:bfriesen)

Thanks Clay, I am very green at this, so I looked at what was exsisting and try to replicate it for my new purpose. I did not think or know about the suggetions you made. I will see what I can figure out.



thank you



Bryon

Announcements

Top Tags