Forum How do I...?

Anchors don't work as expected in XML

StoneCypher
I'm ... quite surprised this doesn't produce a link within the PDF. I've tried it with and without the XML PI, with and without the DTD, the pair.

It's not just an unstyled link; clicking the text produces no activity in a nearby browser.

<?xml version="1.0" standalone="no" ?>
<!DOCTYPE proposal SYSTEM "prop.dtd">

<proposal>
  <a href="http://google.com/">Google link</a>
</proposal>


Am I missing something obvious?

Result PDF is attached.

John Haugeland is http://fullof.bs/

  1. linktest.pdf13.3 kB
StoneCypher
Sorry, I should mention that things work as expected when I'm building from HTML; I've switched to XML so that I can take advantage of DTD expansion.

John Haugeland is http://fullof.bs/

StoneCypher
Okay, it's provably me. Eventually it occurred to me to find an XML sample that has external links, and there's exactly one: the math example.

http://www.princexml.com/samples/math.xml

And, after realizing the reason it didn't work is it refers to an obsoleted W3C DTD standard, I pulled that standard out of the wayback machine.

http://web.archive.org/web/20080403222108/http://www.xml.org/xml/schema/e95210e7/xml.dtd

And whereas for god knows what reason Prince can't consume the Wayback Machine's presentation, probably because of their horribly illegal URLs, if you pull that up in a browser, the browser with face in palm DWIM, and then you can re-host that DTD somewhere else, and suddenly, external links.

So, then, we have something of a notion of what's going on. Facepunch the XHTML attlist out of that XML-PI schema directive, and pow!, away go the links.

So it's actually something in the XHTML schema that makes anchors go vroom. Drop that extension reference into my own document, and Jack-Kirby style Awakathoom!, it starts working.

For readers facing the same problem, you want to add this fragment to your DTD PI:

[<!ATTLIST a xmlns CDATA #FIXED "http://www.w3.org/1999/xhtml">]


Since that's pretty opaque, I'll give you my DTD PI before:

<!DOCTYPE proposal SYSTEM "prop.dtd">


And after:

<!DOCTYPE proposal SYSTEM "prop.dtd" [<!ATTLIST a xmlns CDATA #FIXED "http://www.w3.org/1999/xhtml">]>


This, uh. Should probably be documented somewhere. :) Later I'm going to figure out what in that attribute list actually makes this function. Sadly, this document needs to be out tomorrow morning, so I currently cannot chase the tech monkey.

DAMN YOU, TECH MONKEY!

John Haugeland is http://fullof.bs/

mikeday
In arbitrary XML, there is nothing inherently linky about an element called "a" with an attribute called "href". You can make it a link with a CSS rule like this: "a[href] { prince-link: attr(href) }". Prince already has a default rule like this for elements in the XHTML namespace, eg. elements with xmlns="http://www.w3.org/1999/xhtml" on them. The DTD fixed attribute that you found just adds this namespace declaration to the link. Using the Prince link CSS property is probably simpler, though.