{"id":711,"date":"2007-10-28T13:12:22","date_gmt":"2007-10-28T13:12:22","guid":{"rendered":"http:\/\/www.stevepugh.net\/VTT\/2007\/10\/28\/xpath-puzzle\/"},"modified":"2007-10-28T13:12:22","modified_gmt":"2007-10-28T13:12:22","slug":"xpath-puzzle","status":"publish","type":"post","link":"https:\/\/stevepugh.net\/VTT\/2007\/10\/xpath-puzzle\/","title":{"rendered":"XPath puzzle"},"content":{"rendered":"<p>Any <abbr title=\"XSL Transformations\">XSLT<\/abbr>\/<abbr title=\"XML Path Language\">XPath<\/abbr> experts out there? I&#8217;m a little bit stuck. I have a stylesheet that is effectively transforming <abbr title=\"Extensible HyperText Markup Language\">XHTML<\/abbr> into <abbr>XHTML<\/abbr> (best not to ask) and is matching any element with <code>select = \"xhtml:*\"<\/code>. However, sometimes empty <code>a<\/code> elements creep into the original <abbr>XHTML<\/abbr> and get copied across to the output. These can play havoc with the <abbr title=\"Cascading Style Sheets\">CSS<\/abbr> and JavaScript used on the final web page so I&#8217;d like to supress them.<\/p>\n<p>How do I modify the select statement above to select all <abbr>XHTML<\/abbr> elements except for a elements that have either no text node children or have text node children composed solely of white space?<\/p>\n<p>In other words if the input contains <code>&lt;a&gt;&lt;\/a&gt;<\/code> or <code>&lt;a \/&gt;<\/code> or <code>&lt;a&gt; &lt;\/a&gt;<\/code> then it should be skipped (assume for now that any attributes are irrelevant and that we&#8217;ll deal with the case where it contains another element node but no text nodes later).<\/p>\n<p>I tried <code>select = \"xhtml:*[not(self::a[not(text())])][not(self::a[not(text() = ' ')])]\"<\/code> as a first stab but as well as being very ugly it doesn&#8217;t seem to be working. Any ideas?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Any XSLT\/XPath experts out there? I&#8217;m a little bit stuck. I have a stylesheet that is effectively transforming XHTML into XHTML (best not to ask) and is matching any element with select = &#8220;xhtml:*&#8221;. However, sometimes empty a elements creep into the original XHTML and get copied across to the output. These can play havoc [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2,15],"tags":[268,269],"class_list":["post-711","post","type-post","status-publish","format-standard","hentry","category-computers","category-www","tag-xpath","tag-xslt"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1fxq5-bt","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/posts\/711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/comments?post=711"}],"version-history":[{"count":0,"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/posts\/711\/revisions"}],"wp:attachment":[{"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/media?parent=711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/categories?post=711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepugh.net\/VTT\/wp-json\/wp\/v2\/tags?post=711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}