| Author |
function id() works in the xpath but not in the xsl
|
Cesar Arend
Greenhorn
Joined: Jan 25, 2013
Posts: 1
|
|
Hey I'm from Brazil. So, sorry for my english!
If I consult //jogoGrupo[1]/jogo[1]/selecao/id(@pais) in the xpath I get: Franca e Senegal. However I put this consult int the xsl <xsl:value-of select="//jogoGrupo[1]/jogo[1]/selecao/id(@pais)"/> and doesn't work.
I think the error is in the schema, is it right to declare pais as xs:idref in <selecao pais=s1>, somebody could help me?
XML:
XSL
SCHEMA:
|
 |
g tsuji
Ranch Hand
Joined: Jan 18, 2011
Posts: 357
|
|
I think the error is in the schema, is it right to declare pais as xs:idref in <selecao pais=s1>, somebody could help me?
There is nothing wrong with the schema. It is just fine to declare pais attribute of selecao as xs:IDREF, you don't have to worry about it. If you define it as so xs:string (taking the most liberal view point), you just sacrifice some tighter constraint during validation: but as far as the schema-aware xslt processor is concerned, when you use fn:id(), it will automatically cast the argument into xs:IDREFS. So as long as those strings are of good format such as no whitespace inside, you could get away with unpredictable results as space would be looked as separator of some IDREF's. In simple term, it is just fine to have it as xs:IDREF.
fn:id() works just fine in xslt 2.0.
Now, what is the problem with your xslt? The problem is that you have not imported the schema to it. The consequence of it is that the xslt processor will fall back to it basic version, rather than being schema-aware and hence fn:id() has no place to do with it as it won't recognize who-is-who xs:ID or xs:IDREF. Or in some technical twist, the is-id property is not populated in the data model.
Furthermore, you can take full schema-awareness to stop xslt to output anything at all, which is often most damaging and non-sense, if the xml is invalid. This is realized in the template I add to it matching the loosely document-node(). This is how you can protect the application from this fallout.
Like that, the application would be quite safe guarding against invalidate xml.
|
 |
 |
|
|
subject: function id() works in the xpath but not in the xsl
|
|
|