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

We are working to address an issue with subscription email notifications. In the meantime, be sure to check your favorite boards for new topics.

ufe: with a X-path question (newbee)

bfriesen
17-Peridot

ufe: with a X-path question (newbee)

The problem I am having is the mainbooktitle does show the tm element when publsihing to pdf. We had a style sheet created for us. They add the text to the cover using a _ufe with a x-path reference (/RDStyle/ResolvedMap/servicemanualmap/booktitle/mainbooktitle) in it. My limited understanding of this is that it is going to publish whatever is seen in the mainbooktitle element. So I should also expect that the tm element should also be displayed?


any help would be great


Thanks


Bryon

3 REPLIES 3

Hi Bryon--



It depends on how it is specified. If it is specified as an XPath
*string*, then no, it won't include the TM element. When an XPath node
is specified and the string value is requested, it is the concatenation
of descendant text nodes. Any child elements are stripped out.



If it's specified as Insert Element Content->by XPath, then that should
preserve the child elements of the target node, so that should do what
you want.



--Clay



Clay Helberg

Senior Consultant



TerraXML

1380 Forest Park Circle, Suite 100

Lafayette, CO 80027
bfriesen
17-Peridot
(To:bfriesen)

Hmm my manual title has this line in it. By the xpathstring expr, I take it that this is a a xpath string.


<_gte:XPathString expr="/RDStyle/ResolvedMap/servicemanualmap/*[name()='bookmeta' or name()='servicemanualmeta']/modelno"/><_dtd:_newline/><_gte:XPathString expr="/RDStyle/ResolvedMap/servicemanualmap/booktitle/mainbooktitle"/>


I went into the _ufe and copied the path then went to insert element Content, by xpath and pasted (/RDStyle/ResolvedMap/servicemanualmap/booktitle/mainbooktitle)into the Xpath expression. It now behaves as it should. Is there any reason why you would not want a xpath to pass on child elements?


Thank you Clay.


Bryon

Hi Bryon--



Sure, there are plenty of instances where you want the text content of
an element and not its markup content. For example, you would want this
if you are assigning the content of an element as an attribute value
somewhere else. But beyond that, XPath strings and XPath nodesets
(element content) are two fundamentally different things. You use a
string when you literally want a just a string of text. You use a
nodeset when you want to include processing of the child elements of the
target node (as in your use case).



XPath works on an in-memory DOM tree, so it doesn't have any concept of
markup strings. So there's no way it can get from "a mainbooktitle node
with a child tm node" to a string like "my booktitle<tm type="reg"/">".
XPath has no way of knowing how to transform a <tm> element into text to
include it in a string.



Keep in mind that XPath is a general language for selecting content from
a structured document; it was born completely independently of Arbortext
and Styler. In fact, it's primary usage is in XSLT transformation
stylesheets. So, when thinking about "why does it work that way?", you
have to consider more general cases beyond how it is used in Styler.



--Clay



Clay Helberg

Senior Consultant



TerraXML

1380 Forest Park Circle, Suite 100

Lafayette, CO 80027
Top Tags