processing-instruction

Accessing processing instructions with PHP's SimpleXML

家住魔仙堡 提交于 2021-01-29 17:51:58
问题 Pretty straightforward -- Is there any way to access the data of a processing instruction node using SimpleXML? I understand that SimpleXML is, well, simple; as a result it has a number of limitations, predominantly working with mixed content nodes. An example: Test.xml <test> <node> <?php /* processing instructions */ ?> </node> </test> Parse.php $test = simplexml_load_file('Test.xml'); var_dump($test->node->php); // dumps as a SimpleXMLElement, so it's sorta found, // however string casting

Embedding XML (with XML declaration) in HTML or other XML

孤街浪徒 提交于 2020-02-03 04:04:26
问题 I have the error : Error Parsing /WEB-INF/includes/VerDatosProyeccion.xhtml: Error Traced[line: 4302] The processing instruction target matching "[xX][mM][lL]" is not allowed. I am using the code of same code of : http://jsfiddle.net/qxLn3h86/. I cut the code and past into my code. My code looks like this : <table id="tbl1"> <tr> <td>Name</td> <td>Birthday</td> <td>Amount</td> <td>Rebate (10%)</td> </tr> <tr> <td>Smith</td> <td data-type="DateTime" data-style="Date" data-value="1980-03-23"

matching the following and call template

随声附和 提交于 2019-12-12 01:45:50
问题 This is a simplified XML which exposes the general structure of the problem I have. <chapter num="07"> <title> <page num="703"/> ... text (mixed content) ... </title> <page num="704"/> <section level="sect1"> <title>...text...</title> <para num="7.1.1">... a lot of text (mixed content)...</para> </section> <section level="sect1"> <title>... text... </title> <para num="7.2.1">Some text... <footnoteref linkend="fn3" num="3"/> <footnote num="3" id="fn3"> ... mixed content ...</footnote> ...more

How to add XML processing instructions during JAXB marshal

二次信任 提交于 2019-12-05 00:41:56
问题 I would like to add a processing instruction whenever a collection/array property is serialized to get something like <alice> <? array bob ?> <bob>edgar</bob> <bob>david</bob> </alice> Is this possible with JAXB? Or at least with some specific JAXB implementation? 回答1: You could leverage an XMLStreamWriter and an XmlAdapter to do this: BobAdapter Things to note about the XmlAdapter : It's stateful and references an XMLStreamWriter . We will later leverage JAXB's ability to set a stateful

How to add an xml-stylesheet processing instruction node with Python 2.6 and minidom?

ⅰ亾dé卋堺 提交于 2019-12-04 01:32:51
问题 I'm creating an XML document using minidom - how do I ensure my resultant XML document contains a stylesheet reference like this: <?xml-stylesheet type="text/xsl" href="mystyle.xslt"?> Thanks ! 回答1: Use something like this: from xml.dom import minidom xml = """ <root> <x>text</x> </root>""" dom = minidom.parseString(xml) pi = dom.createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="mystyle.xslt"') root = dom.firstChild dom.insertBefore(pi, root) print dom.toprettyxml() => <

Is there any way to call XSLT templates inline

笑着哭i 提交于 2019-12-01 09:24:05
How to call XSLT templates inline? For instance, instead of : <xsl:call-template name="myTemplate" > <xsl:with-param name="param1" select="'val'" /> </xsl:call-template> Can I use XSLT built-in function-call style, like this: <xls:value-of select="myTeplate(param1)" /> In XSLT 2.0 you can define your own custom functions using xsl:function An article on XML.com describing how to write your own functions in XSLT 2.0: http://www.xml.com/pub/a/2003/09/03/trxml.html <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://whatever"> <!-- Compare two strings

How to add an xml-stylesheet processing instruction node with Python 2.6 and minidom?

天涯浪子 提交于 2019-12-01 06:15:40
I'm creating an XML document using minidom - how do I ensure my resultant XML document contains a stylesheet reference like this: <?xml-stylesheet type="text/xsl" href="mystyle.xslt"?> Thanks ! Use something like this: from xml.dom import minidom xml = """ <root> <x>text</x> </root>""" dom = minidom.parseString(xml) pi = dom.createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="mystyle.xslt"') root = dom.firstChild dom.insertBefore(pi, root) print dom.toprettyxml() => <?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="mystyle.xslt"?> <root> <x> text </x> </root> I am

Is there any way to call XSLT templates inline

こ雲淡風輕ζ 提交于 2019-12-01 05:36:03
问题 How to call XSLT templates inline? For instance, instead of : <xsl:call-template name="myTemplate" > <xsl:with-param name="param1" select="'val'" /> </xsl:call-template> Can I use XSLT built-in function-call style, like this: <xls:value-of select="myTeplate(param1)" /> 回答1: In XSLT 2.0 you can define your own custom functions using xsl:function An article on XML.com describing how to write your own functions in XSLT 2.0: http://www.xml.com/pub/a/2003/09/03/trxml.html <xsl:stylesheet version=

How to read processing instruction from an XML file using .NET 3.5

半腔热情 提交于 2019-12-01 03:20:37
问题 How to check whether an Xml file have processing Instruction Example <?xml-stylesheet type="text/xsl" href="Sample.xsl"?> <Root> <Child/> </Root> I need to read the processing instruction <?xml-stylesheet type="text/xsl" href="Sample.xsl"?> from the XML file. Please help me to do this. 回答1: How about: XmlProcessingInstruction instruction = doc.SelectSingleNode("processing-instruction('xml-stylesheet')") as XmlProcessingInstruction; 回答2: You can use FirstChild property of XmlDocument class and

Handling <?xml-stylesheet> similar to <link rel=“stylesheet”>?

こ雲淡風輕ζ 提交于 2019-11-29 11:41:16
During investigation of advantages and disadvantages of attaching CSS with <?xml-stylesheet> processing instruction, I came upon some issues. Suppose we have a simple XHTML document (which is delivered with application/xhtml+xml MIME type and viewed in a Web browser): <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>A sample XHTML document</title> <script type="application/javascript" src="/script.js"></script> </head> <body> <h1>A heading</h1> </body> </html> Then we have an external CSS file (let it be named style.css and put in root directory): h1 { color: red; } At