Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

xml declaration a PI?

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this question from a mock exam offered by www.witscale.com. I read from prof. xml book that XML declaration is not a PI. But this mock exam says it is a PI. Which is correct..I'm confused.
I think the correct answer for this question is 1.
2 - not correct since it is a xml declaration
3 - not correct since xsl:stylesheet does not start with ?
4 - not correct since it is a dtd declaration
5 - not correct since it does not end with "?>"
6 - not correct since it is also a xml declaration.
<?xml-stylesheet type="text/xsl" href="style.xsl" ?>

<?xml version="1.0" ?>

<?xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"?>;

<!DOCTYPE name SYSTEM "" >

<?xml-stylesheet type="text/xsl" href="style.xsl" >

<?xml version="1.0" encoding="UTF-8"?>



--------------------------------------------------------------------------------
Correct answer is 1,2,5 and 6.
Option3 is incorrect <xsl:stylesheet> is not processing instruction and does not
start with ?. Option4 is DTD declaration and it too is not a processing

Thanks
Shoba
 
Shoba Ramachandran
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Even the xslt tutorial given in www.xfront.com also says that xml declaration is a PI. Please refer to xsl2.ppt of that tutorial.
Please somebody clarify me.
Thanks
Shoba
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The XML declaration statement is not a PI. This is what is mentioned in the W3C specs.
Vibha.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Shoba, Ramachandran:
I got this question from a mock exam offered by www.witscale.com. I read from prof. xml book that XML declaration is not a PI. But this mock exam says it is a PI. Which is correct..I'm confused.
I think the correct answer for this question is 1.
2 - not correct since it is a xml declaration
3 - not correct since xsl:stylesheet does not start with ?
4 - not correct since it is a dtd declaration
5 - not correct since it does not end with "?>"
6 - not correct since it is also a xml declaration.
<?xml-stylesheet type="text/xsl" href="style.xsl" ?>

<?xml version="1.0" ?>

<?xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"?>;

<!DOCTYPE name SYSTEM "" >

<?xml-stylesheet type="text/xsl" href="style.xsl" >

<?xml version="1.0" encoding="UTF-8"?>



--------------------------------------------------------------------------------
Correct answer is 1,2,5 and 6.
Option3 is incorrect <xsl:stylesheet> is not processing instruction and does not
start with ?. Option4 is DTD declaration and it too is not a processing

Thanks
Shoba


Hi,
You are absolutely correct as far as the answers to your postage is concerned .
Whether "XML declaration is a PI or not" is indeed a confusing question but the very fact that it is given in W3C specs that it is NOT a PI tilts the scale in its favor.
I m pasting the relevant details from W3C specs.
2.6 Processing Instructions
[Definition: Processing instructions (PIs) allow documents to contain instructions for applications.]
Processing Instructions
[16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
[17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
Thanks,
Sudhakar
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Therefore declaration
<?xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"?>;
is PI too!
xsl:stylesheet - valid name
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; - valid instruction
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all i guess <?xml version=1.0"?> is a processing instruction if we look at it as per the definition of a PI which has to start with <? and end with ?>; Also xml bible clearly states this fact;
Also, if we try to use xsl:stylesheet as the target for a PI, we get the following error -
"Entity names, PI targets, notation names and attribute values declared to be of types ID, IDREF(S), ENTITY(IES) or NOTATION
=====cannot contain any colons.==== "
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Jayadev,
As Sudhakar pointed out, the W3C spec states that:
2.6 Processing Instructions
[Definition: Processing instructions (PIs) allow documents to contain instructions for applications.]
Processing Instructions
[16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
[17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))

Hence "xml" would be an invalid target name, thus <?xml version=1.0"?> cannot be a PI.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the clarification
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic