English 中文(简体)
格式不好
原标题:Not well formatted xml JAXB

m trying using the JAXB annotations to send and xml file but I saw that the nodes has this format:

<:subject xmlns="http://www..." xmlns:atom="http://www.w3.org/2005/atom">
 <:data>maths<:data>
</:subject>

而不是:

<subject xmlns="http://www..." xmlns:atom="http://www.w3.org/2005/atom">
 <data>maths<data>
</subject>

I can t understand why this happens. From where insert the : symbol and why? T

My model has this form:


@XmlRootElement(name="subject")
@XmlAccessorType(XmlAccessType.FIELD)
public class Registration {

   private String data;

    get/set
}

我的包裹——Info.java:

  @javax.xml.bind.annotation.XmlSchema (
   namespace="http://www..",
   elementFormDefault=XmlNsForm.QUALIFIED,
xmlns = { 
  @javax.xml.bind.annotation.XmlNs( prefix=" ", namespaceURI="http://www..."),
  @javax.xml.bind.annotation.XmlNs( prefix="atom" ,namespaceURI="http://www.w3.org/2005/atom")
})

 package mypackage.affil;

 import javax.xml.bind.annotation.XmlNsForm;

我认为:

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
 <%@ page language="java" contentType="text/html"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html">
<title>Insert title here</title>
</head>
<body>

<h1>Create New Person</h1>

<c:url var="takeinto" value="/takedata" />
<form:form modelAttribute="takedataAttribute" method="POST" action="${takeinto}">
<table>
    <tr>
        <td><form:label path="data">Affiliation</form:label></td>
        <td><form:input path="data"/></td>
    </tr>

谁能告诉我,文号是:出现在什么?

问题回答

你们在那里触发了奇怪的 b! 我的猜测是,问题在于此(我删除了 Java名称,你可以通过在<条码>后填入右栏“进口<>/条码>声明”来填写这些名称:

@XmlSchema (
    namespace="http://www..",
    elementFormDefault=XmlNsForm.QUALIFIED,
    xmlns = { 
        @XmlNs( prefix=" ", namespaceURI="http://www..."),
        @XmlNs( prefix="atom" ,namespaceURI="http://www.w3.org/2005/atom")
})

I m guessing that it is a combination of using a single empty string for the prefix and QUALIFIED for elementFormDefault. Try this instead:

@XmlSchema(
    namespace="http://www..",
    elementFormDefault=XmlNsForm.UNQUALIFIED,
    xmlns = { 
        @XmlNs(prefix="atom", namespaceURI="http://www.w3.org/2005/atom")
})

That is, UNQUALIFIED and only providing xmlns for the parts that you want qualified. It s possible that you ll need to specify the namespace on @XmlElement tags throughout (the documentation is somewhat unclear) so I also recommend refactoring that out into a constant in an interface; that makes things clearer too.





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签