hi, i have a system that generates xml which i am then styling with css. i'm attempting to use php to run prince (so far unsuccessful, but i know it works on the server through Terminal), i have a foreach loop generating an ordered list, and my question is this: what does prince recognize as a link and how can i make sure it puts that link into the pdf? for example, my foreach loop looks for <formName></formName> and puts the values stored inside that tag inside an ordered list. how then do i link from the ordered list to the actual <formName>? i've tried adding <formName id='item1'> then <a href="#item1">Item 1</a> to the ordered list's <li>
Forum › How do I...?
create links using xml?
If you're using HTML then that should work fine, if it's an arbitrary XML document and you want to include bits of XHTML then you'll have to place the <a> element in the XHTML namespace, or use XLink, or use the prince-link property (see the default xhtml.css file in the Prince installation for an example of how to do this).
thanks for the reply, could you be a little more specific in examples? it is an arbitrary xml document, and do you mean including the <a> element like this:
<a name="item1"><formId>Form A</formId></a>
cause that didn't work...
and i found the prince-link property within the xhtml css and read the page you referenced, but i still don't understand how it works.
<a name="item1"><formId>Form A</formId></a>
cause that didn't work...
and i found the prince-link property within the xhtml css and read the page you referenced, but i still don't understand how it works.
If you look in xhtml.css or xhtml-ns.css you will see the following rule:
This turns <a href="URL"> elements into a link that points at URL. The reason why this isn't automatically working for you is that your document is arbitrary XML, not HTML, so only the xhtml-ns.css default style sheet will be applied. This has the same style rules, but only applies them to elements that are explicitly using the XHTML namespace, so that non-HTML elements are not incorrectly styled. (For example, an XML document might be using <table> to refer to furniture of some kind). If you place your link element in the XHTML namespace, it should work:
If you don't want to deal with XML namespaces, then you can just add your own style sheet with a prince-link rule similar to the one listed above, and it should also work.
a[href] {
...
prince-link: attr(href)
}
This turns <a href="URL"> elements into a link that points at URL. The reason why this isn't automatically working for you is that your document is arbitrary XML, not HTML, so only the xhtml-ns.css default style sheet will be applied. This has the same style rules, but only applies them to elements that are explicitly using the XHTML namespace, so that non-HTML elements are not incorrectly styled. (For example, an XML document might be using <table> to refer to furniture of some kind). If you place your link element in the XHTML namespace, it should work:
<a xmlns="http://www.w3.org/1999/xhtml" href="URL">
If you don't want to deal with XML namespaces, then you can just add your own style sheet with a prince-link rule similar to the one listed above, and it should also work.