JAXB:  How do I add xml declaration?

Hi there
How do I add <?xml-stylesheet ... > while constructing a JAXB object befor the marshalling process?
Please help?
Thanks
~Glen

Hi there
How do I add <?xml-stylesheet ... > while constructing
a JAXB object befor the marshalling process?
Please help?
Thanks
~GlenIf you see there is an example on xml-stylesheet in the jaxb1.0
bundle.
That will show you how to insert the xml-stylesheet in your processingInstruction.
Thanks,
Bhakti

Similar Messages

  • How to add XML declaration to document using JDOM?

    Hi, there:
    I am trying to create a document. I want to add the following xml declaration to
    the document:
    <?xml version="1.0"?>
    JDOM Document class can add elements and attributes or doctype, does it have ability to add xml declaration to the very start of a document?
    regards,

    that line should be added automatically to the document when you serilize your DOM.

  • How to exclude the XML declaration from each row of the result set?

    Hi,
    I have a table with an XMLTYPE column and would like to SELECT a set of rows. How can I exclude the XML declaration from each row in the result set? My query currently looks like this, I'm executing it through Spring JDBC:
    SELECT XMLSerialize(CONTENT t1.xmltext) FROM myschema.event t1 WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e") ORDER BY t1.time DESC
    After selecting, in my application I convert each row into a String and concatenate all rows into one big string in order to parse it into a DOM model. I get a parser exception (org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed) because there are multiple XML declarations in my big string. Of course, I could manually check the String of each row whether it starts with the XML declaration, but it would be nicer if I could instruct the DB not to add it in the first place. Is there a way?
    Thanks!
    -- Daniela

    Hi,
    A couple of options I can think of :
    SELECT XMLSerialize(CONTENT
    XMLtransform(t1.xmltext,
      xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes"/> 
    <xsl:template match="/"><xsl:copy-of select="*"/></xsl:template>
    </xsl:stylesheet>')
    FROM myschema.event t1
    WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e")
    ORDER BY t1.time DESC
    ;or simply,
    SELECT XMLSerialize(CONTENT
      extract(t1.xmltext,'/')
    FROM myschema.event t1
    WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e")
    ORDER BY t1.time DESC
    ;

  • JAXB: How do I add a processing instruction?

    Hi there
    I am using XML with JAXB in a client/server environment. On the response of from the server to the client, I want to include a processing instruction in the XML response to indicate a stylesheet associated for example:
    <?xml-stylesheet type="text/xsl" href="test.xsl"?>
    Does anybody have any ideas on how to include a stylesheet while constructing the jaxb object? Or must this declaration be included in the building schema???
    Please help?
    Thanks
    Glen

    this is how I do it in jwsdp 1.4:
    marshaller.setProperty("com.sun.xml.bind.xmlHeaders", "<?xml-stylesheet type=\"text/xsl\" href=\"checker.xslt\"?>");
    This constant is defined as private in the generated marshal class.
    as of now this looks like an undocumented feature.

  • JAXB: How to unmarshal from xml contains two schemas?

    Hi, all.
    My question is in subject.
    Ex.)
    schema1.xsd:
    (snip)...
    <xsd:element name="xxx">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    ...(snip)
    schema2.xsd:
    (snip)...
    <xsd:element name="yyy">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="zzz" minOccurs="1" maxOccurs="1"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="zzz" type="xsd:string"/>
    if I have a xml like the following, xml validation is correct:
    sample.xml:
    (snip)...
    <ns1:xxx xmlns:ns1="...(schema1.xsd)...">
    <ns2:yyy xmlns:ns2="...(schema2.xsd)...">
    <ns2:zzz>SAMPLE</ns2:zzz>
    </ns2:yyy>
    </ns1:xxx>
    I want to unmarshal from this xml using JAXB, but actually ths xxx didn't have any tag in List class given getAny() method, because xxx doesn't know about yyy, I think.
    These schemas cannot change as requirements of customer.
    How to unmarshal from xml contains two schemas using JAXB?
    tx.

    I solved it myself.
    JAXBContext can be specified many context path at same time.
    Ex.)
    context = JAXBContext.newInstance("package1:package2:package3...");
    So, unmarshaller can know how to choose what be instanced.
    tx.

  • How can I add XML metadata to simulate my application?

    I have a client application I support and I'm trying to use Dreamweaver as a tool to customize pages within the application. Each page, or report, consists of a HTM file with supporting CSS and Jscript used to render a view of data from the server that comes in the form of an XML file.  The HTM file is viewed file with the CSS / Jscript working as is, but i'm trying to determine how to get the XML payload from the server to populate the elements in the HTM file.  below is a sample of the supporting files, the first shot is the XML payload the server sends, the second shot is the client files used to create the report.  All i need to do is 'attach' the XML to the htm file in dreamweaver so i can apply changes and see how effects of my work in the design view.  Is this possible?  All these files will be client side...

    The solution from dvohra09 will output a file outXml that uses the format rules from stylesheet.
    But how can I write out the following 2 lines to outXml? contextHandler.startDocument() will only write out the first line, but not the second line...
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="mytest.xsl"?>
    Thanks for all pointers!
    Philip

  • How to specify the XML Declaration for an XML variable

    I need to set the XML declaration for my XML variable as
    follows:
    var employees:XML =
    <?xml version="1.0" encoding="utf-8"?>
    <employees>
    <employee ssn="123-123-1234">
    <name first="John" last="Doe"/>
    <address>
    <street>11 Main St.</street>
    <city>San Francisco</city>
    <state>CA</state>
    <zip>98765</zip>
    </address>
    </employee>
    <employee ssn="789-789-7890">
    <name first="Mary" last="Roe"/>
    <address>
    <street>99 Broad St.</street>
    <city>Newton</city>
    <state>MA</state>
    <zip>01234</zip>
    </address>
    </employee>
    </employees>;
    However, if I specify <?xml version="1.0"
    encoding="utf-8"?>, I get a design time and compile error. If I
    remove it it works fine. But the server to which I send this XML is
    expecting the declaration. Can somebody help me with this?
    Thanks

    I work mostly with the Java versions of the parser so you'll have to make the translation to C++. As far as I know, you can't use the SAX API to access to the encoding.
    You need to use the DOM along with Oracle's extension to the basic DOM functionality. Oracle's package, oracle.xml.parser.v2 defines a class which implements the Document interface called XMLDocument. This class has a method, getEncoding(), which returns the encoding. You would use the method in getDocument() in the Parser base class inherited by DOMParser to retrive the XMLDocument.
    Jeff

  • How do I add XML content to existing FrameMaker Document

    Hello,
    I have an XML document that contains features of one item and I want to add data from it to FM document that shows those features. These features have been added to FM previously by copy-paste technology which isn't obviosly the fastest way and I have understood adding them automatically is possible.
    I can read XML well and I can produce XSLT files to make another XML files, problem is that I'm a little beginner with FM and help files didn't show any good examples of this (or at least I didn't find). I tried to do some read/write rules, because it seemed to be the way how FM handles these things but they didn't work.
    So shortly: XML file (data) + FM file (tables and such) = FM file which have XML data in its tables
    I would appreciate any help, like pointing to right help files or such, thanks in advance.

    The two main references you need are:
    Developing Structured Applications with FrameMaker, Guide
    Developing Structured Applications with FrameMaker, Reference
    They used to ship with FrameMaker, but you can download them from the Adobe site. Check the Support section. I do not believe they are available for FrameMaker 10 yet, but they are for version 9. No matter your FramMaker version, almost any set will do.
    Basically, you need an XSLT that will translate the XML structure into the structure you use in your FrameMaker files. You need a set of read/write rules (see the references above). FrameMaker uses read/write rules to specify how certain FrameMaker objects are to be translated from the XML. Such objects include tables, variables, and markers.
    Then you need to create a structured application that specifies where the XSLT, the read/write rules, and your structured template are located on you system.Again, see the references.
    Once all of the above is in place, you open the XML file from within FrameMaker. FrameMaker will ask you what structured application to use, which you pick from the dropdown list. It will then open the XML file, apply the XSLT transformation, and copy the result into your structured blank template. That process will likely list several errors, which you may or may not be able to ignore depending upon the resulting FrameMaker document. In my case, these are usually errors about missing graphics, which I already know are missing.
    The result is ONE FrameMaker file. You can then copy and paste the information where ever you need it in your other documents. I am not sure whether you can import an XML file into an existing Framemaker document, much like a text inset. Maybe others will know.
    Good luck,
    Van

  • Add xml Tags in Indesign CS4 by Apple/Java script

    Hi,
    All, I'm new to Indesign Scripting, and I'm hoping someone can help me with the following add xml tags in my xml indesign cs4 files.
    I have IDML (ETMV2) xml Indesign CS4 files. But i have lots of powermath equation without xml tags. So i want how i can insert xml tags.
    My probleam like this =>
    <no open xml tags>[&x^{2}+y_{3}&]<no close xml tags>
    I want like this (But i do manualy)
    <inlineequation><inlinemediaobject><textobject role="xpressmath">[&x^{2}+y_{3}&</textobject></inlinemediaobject></inlineequation>
    Can anyone write/suggest me how i can add xml Tags. By Apple/Java Script
    Any insight is appreciated!
    snegig

    Hi,
    John Hawkinson thank you so much your suggestion.
    I am new  this type of discusion (on this page). So i think anybody could not replay my answer. So i repost my question.
    I want insert tags in my Indesign CS4 files. Is this posible when i select my powermath equaiton then run script. Script add tags automatically before/after my equation. Please ignore IDML word.
    Yes i an comfortable with XSLT presently i working with Pearson ETMV2.
    I have one more question when i past my snapshot its appear properly but when i agin see my commant then my snapshot disappear (see small blue rectangle).
    Thank you John again i am new in this industry please guide.
    snegig

  • Need to add xml tag in the request message

    Hello Experts,
    Need ur help.
    Right now i am working on the scenario Http -> to -> Proxy.
    Whatever request i am getting is not having XML tag in it, and because of that my mapping is failing.
    Can you tell me that how can i add XML tag in my request so it will not fail in Mapping?
    Need to add : <?xml version="1.0" encoding="UTF-8"?> in request.
    Thanks,
    Hetal

    HI Hetal
    Instead of adding this to the source message. Remove this tag from mapping.
    Use a XSLT mapping without this initial tag. it will work.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:m="http://namespace">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
    <xsl:template match="/">
    <xsl:for-each select="//tag">
    <xsl:value-of select="." disable-output-escaping="yes"/>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    Use this mapping without
    <?xml version="1.0" encoding="UTF-8"?>
    If you still see XML tag then use
    <xsl:output method="html"
    instead of
    <xsl:output method="xml"
    Thanks
    Gaurav

  • Add xml Tags by Apple/Java script

    Hi,
    All, I'm new to Indesign Scripting, and I'm hoping someone can help me with the following (add xml) problem.
    Can anyone write/suggest me how i can add xml tags. By Apple/Java Script
    My Probleam =>
    [&x+2, y+3&]
    Solution => (But its manual)
    <inlineequation><inlinemediaobject><textobject role="xpressmath">[&x+2, y+3&]</textobject></inlinemediaobject></inlineequation>
    I want add xml tags on my powermath equaiton. Its ETMV2 xml tags.
      Any insight is appreciated!
    Thank you so much
    snegig

    Hi John,
    (1) Without xml tags my InDesign file
    (2) After add tags my file (its manually)
    Is this any script when i select my power math equation data then add xml tags automatically
    Thank's any suggestion

  • Get XML Declaration To Appear in XML

    I have a program that takes a text file and converts it to XML. I dont know how to get the XML declaration to appear at the top of th XML.
    Heres what I got:
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.FileReader;
    import java.io.IOException;
    import org.jdom.Element;
    import org.jdom.output.XMLOutputter;
    public class XML_builder {
         public XML_builder() { }
         public static void main(String[] args){
              testBuildXML();
         private static void testBuildXML(){
              try{
                   String textFile = "P://Useful Docs/Programming/Java/Automated Texting/Automated Texting/phoneNumbers.txt";
                   String XMLFile = "P://Useful Docs/Programming/Java/Automated Texting/Automated Texting/phoneNumbers.xml";
                   File text = new File(textFile);
                   FileReader reader= new FileReader(text);
                   BufferedReader buffer=new BufferedReader(reader);
                   String temp="";
                   int x=0;
                   Element element = new Element("phone_numbers");
                   while ((temp = buffer.readLine())!= null){
                        Element child_node = new Element("number_"+x);
                        System.out.println(temp);
                        child_node.addContent(temp);
                        x++;          
                        element.addContent(child_node);
                   FileWriter writer = new java.io.FileWriter(XMLFile);
                   XMLOutputter xmloutputter = new XMLOutputter();
                   xmloutputter.output(element, writer);
                   catch (IOException exception){
                        System.out.println(exception);
         }Message was edited by:
    paul_carron

    you are printing an element. Create a Document, then output it using the outputter.
    Document doc = new Document(element);
    xmloutputter.output(doc, writer);~Tim
    Message was edited by:
    SomeoneElse

  • How to change xml declaration using jaxb Marshaller

    please, my xml declaration, in the output file generated by jaxb: javax.xml.bind.Marshaller is:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    I need to change it in:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="style.xsl"?>
    I don't have idea about how to change.
    thanks a lot alessandro

    Hello.
    public void saveJaxbObjectToFile(String packageName, Object myJaxbObject, String fileName)
    throws JAXBException, ParserConfigurationException, TransformerConfigurationException,
    TransformerException, FileNotFoundException, IOException {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db = dbf.newDocumentBuilder();
    org.w3c.dom.Document document = db.newDocument();
    JAXBContext jAXBContext = JAXBContext.newInstance(packageName);
    Marshaller m = jAXBContext.createMarshaller();
    m.marshal(myJaxbObject, document);
    ProcessingInstruction processingInstruction = document.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"style.xsl\"");
    Node rootElement = document.getDocumentElement();
    document.insertBefore(processingInstruction, rootElement);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty("indent", "yes");
    transformer.setOutputProperty("encoding", "UTF-8");
    transformer.setOutputProperty("version", "1.0");
    FileOutputStream fos = new FileOutputStream(fileName);
    transformer.transform(new DOMSource(document), new StreamResult(fos));
    fos.flush();
    fos.close();
    Good luck.

  • How to remove the standalone="yes" attribute in the xml declaration?

    Hi,
    I am using JAXB 2.0 to generate XML files. Can anyone tell me how to remove the standalone="yes" attribute in the xml declaration? Thanks in advance.
    -Joey

    Just open the file with your favorite text program and type away. If you get a permissions problem (file is locked by...) then just stop tomcat and open/edit/save the file and restart tomcat.
    I also think that the admin context that comes with tomcat might allow you to modify/add/edit your users (not sure though)

  • How do i add a newline or carriage return to make my xml file look pretty?

    Hi guys
    I'm writing an xml file with jsp, the problem is, it writes it in one big chunk of text. e.g.
    <start>hello, my name is joe</start><middle>I like trees</middle><end>boo</end>
    Now what I want to do is present this xml file in a decent manner,
    e.g.
    <start>hello my name is joe</start>
    <middle>i like trees</middle>
    <end>boo</end>
    i've tried
    xmlFile = "<start>Hello my name is joe</start>"+\n\r;
    and
    xmlFile ="<start>Hello my name is joe</start>"+"\n\r";
    neither work, can anyone provide me with some insight into how I can add a carriage return / new line to make my xml file look pretty?
    Many thanks for any responses!

    u r right <BR> tag will not work...
    I wrote following code to generate xml file and it works fine...U can try the same...
    try
    FileOutputStream fos = new FileOutputStream("c:\\temp.xml");
    String xmlString = "<root>\n<start>Hello my name is joe</start>"+"\n";
    xmlString = xmlString +"<middle>blah blah</middle>\n</root>";
    fos.write(xmlString.getBytes());
    fos.close();
    fos = null;
    catch(Exception e)
    e.printStackTrace();
    }

Maybe you are looking for

  • How can I create a fIlter to delete only "junk" from the server?

    One of my E-mail accounts is that of a major client. I handle their customer service online. Normally our protocol is to always leave all messages on the server, so for that one Thunderbird account, I have it set to never delete messages on the serve

  • Gif export

    I have created a nice flash file for our website and there is a desire to add it to a e-mail campaign. Flash does not work with our current e-mail tools, so I was thinking of exporting to Gif. Though when I do so. the animation disappears and becomes

  • How do I print from my iPad 3 using a Canon printer?

    I just got the new iPad 3 and I was wondering if anybody could help me out. I hope this is possible, but I was trying to print from my iPad 3 using my Canon MP640r printer. I understand that it's not a Mac printer and there are only certain printers

  • How can i get my mac to trust my iPhone when i have smashed the screen

    I have smashed the screen on my iPhone 6 and it is not recognising finger touch at all. I have plugged it into my Mac so I can back it up. My mac is recognising the phone but as I have not used my phone with my mac before it is asking me to press tou

  • Still image size limit?

    Is there a pixel count limit for still images one wishes to use in iMovie '09? I want to do a long Ken Burns from top to bottom over a piece of art around 10,000 pixels tall.