Forum Moderators: open

Message Too Old, No Replies

Ignore unbound namespaces?

xlink

         

rfafad

7:06 pm on Jan 27, 2021 (gmt 0)

5+ Year Member



XSLT has
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:xlink="http://www.w3.org/1999/xlink">

Source docs (45k + of them) "lost" the xmlns:xlink="http://www.w3.org/1999/xlink" attribute on the root tag.
Source docs have within them several <xentry xlink:href="P.xml#p07-683300">Pediculus.</xentry>

Is there a way to get the XSLT to run, besides adding the missing attribute to the 45k + sources docs?

NickMNS

3:30 am on Jan 28, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there a way to get the XSLT to run, besides adding the missing attribute to the 45k + sources docs?

I don't know anything about xml, albeit it looks very similar to SVG. That said, adding a single line of code to a few, many or 45k documents is a straight forward task, it can be easily done with a short python script, or using SED directly in Linux. It seems like it would be quicker and eliminate any potential confusion in the future caused by running some convoluted workaround.

phranque

3:52 am on Jan 28, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



...adding a single line of code to ... documents is a straight forward task, it can be easily done with a short .. script, or using SED ... would be quicker and eliminate any potential confusion in the future...

^^THIS^^

phranque

3:53 am on Jan 28, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



also, welcome to WebmasterWorld [webmasterworld.com], rfafad!

rfafad

6:28 pm on Jan 28, 2021 (gmt 0)

5+ Year Member



I could do it in no time with Perl, but there's more to the problem than that preventing that obvious solution, which is why I'm looking for another solution besides adding the missing attribute to the 45k + sources docs.
If anyone with XSLT insight can offer a solution, I'm still listening.

phranque

4:07 am on Jan 29, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you might be able to find an XSLT processor that will somehow ignore or work around the malformed XML, but then it depends on the XSLT processor.

this is pretty clear:
The namespace prefix, unless it is xml or xmlns, must have been declared in a namespace declaration attribute in either the start-tag of the element where the prefix is used or in an an ancestor element (i.e. an element in whose content the prefixed markup occurs). The prefix xml is by definition bound to the namespace name [w3.org...] The prefix xmlns is used only for namespace bindings and is not itself bound to any namespace name.

This constraint may lead to operational difficulties in the case where the namespace declaration attribute is provided, not directly in the XML document entity, but via a default attribute declared in an external entity. Such declarations may not be read by software which is based on a non-validating XML processor. Many XML applications, presumably including namespace-sensitive ones, fail to require validating processors. For correct operation with such applications, namespace declarations must be provided either directly or via default attributes declared in the internal subset of the DTD.

source: Namespaces in XML
https://www.w3.org/TR/xml-names11/#ns-qualnames

rfafad

8:47 pm on Jan 29, 2021 (gmt 0)

5+ Year Member



Hmmm...it looks like i have to do it the hard way. Thanks for your time, everyone.