Modify existing XML stylesheet processing instruction in Java -
i'm reading existing xml file , outputting (using dom).
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="test"?> <books> <book name="mybook" /> </books>
but how modify xml stylesheet? -> href here set "test".
something should work (untested)
element root = doc.getdocumentelement(); xpath xpath = xpathfactory.newinstance().newxpath(); string expression = "/processing-instruction('xml-stylesheet')"; processinginstruction pi; pi = (processinginstruction)xpath.evaluate(expression, doc, xpathconstants.node); pi.setdata("type='text/xsl' href='foo.xsl'");
Comments
Post a Comment