-
Entity Referencing
Hello, recently I have started to learn about the xml language. And now I want to get some basic information about it. I want to know the Entity referencing. If anyone knows the details then please reply me about it. If anyone is having information about the sources then also provide me that, so that I can read from there.
-
Re: Entity Referencing
Basically entity referencing is the reference of the entity with the use of its name which will cause it to be inserted into the document in the place where entity exist. If you want to create the entity reference then your entity name must be surrounded by the ampersand and a semicolon as below:
&<name of the entity>;
-
Re: Entity Referencing
Hi, I am not having any type of knowledge about the XML, but while searching on internet I come to know that you can able to get information about the Entity Referencing by the use of the book of Michael Fitzgerald which is having name as Learning XSLT. So, it may be helpful to you to get more basic information about the Entity Referencing and also about the xml basic concepts. So, make use of it.
-
Re: Entity Referencing
I have got the basic code about the Entity Referencing and you can simply make use of it for getting more knowledge about it.
Code:
package javaxml3;
import java.io.FileInputStream;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.occurs.XMLEvent;
public class EntityRef {
public static void main(String[] args) throws Exception {
XMLInputFactory IF = XMLInputFactory.newInstance();
IF.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
IF.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);
XMLStreamReader rdr = IF.createXMLStreamReader(new FileInputStream("sample/entity1.xml"));
System.out.println(rdr.getProperty(XMLInputFactory.IS_COALESCING));
System.out.println(rdr.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES));
while (rdr.hasNext()) {
int occur = rdr.next();
if (occur == XMLStreamConstants.CHARACTERS)
System.out.println(rdr.getText());
else if (occur == XMLStreamConstants.ENTITY_REFERENCE) {
System.out.println("en: "+rdr.getLocalName());
System.out.println("er: "+rdr.getText());
}
}
System.out.println("---------------------");
IF.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
rdr = IF.createXMLStreamReader(new FileInputStream("sample/entity1.xml"));
System.out.println(rdr.getProperty(XMLInputFactory.IS_COALESCING));
System.out.println(rdr.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES));
while (rdr.hasNext()) {
int occur = rdr.next();
if (occur == XMLStreamConstants.CHARACTERS)
System.out.println(rdr.getText());
else if (occur == XMLStreamConstants.ENTITY_REFERENCE) {
System.out.println("en: "+rdr.getLocalName());
System.out.println("er: "+rdr.getText());
}
}
}
}
-
Re: Entity Referencing
You can use differnt books to get the knowledge about the xml. Below are some good books.
Books for XML:
- XML Complete by Steven Holzner
- Presenting XML by Richard Light
- XML: Extensible Markup Language by Elliotte Rusty Harold
- XML: Principles, Tools, and Techniques by Dan Connolly
- The XML Handbook by Charles F. Goldfarb, Paul Prescod
-
Re: Entity Referencing
Syntax:
Code:
&<name of the entity>;
It is the referencing of the entity simply using name of it. If you are using name of it then you will able to insert the reference into the document in place of the entity. So, it will cause simple for you. So, just use the above syntax and get the solution.
Page generated in 1,750,860,525.50740 seconds with 10 queries