Schematron and Java
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Thu Feb 04, 2010 11:15 pm
Schematron and Java
Hello,
I have an xml file structured like this:
I validate this xml (I omitted the headers) with this schematron rule called from Java code:
The sequence index for nodeB is displayed correctly, while the sequence index of nodeA creates problems. It says the operator - cannot operate on a sequence than more than one number, meaning index-of returns more than one index for nodeA. How can this happen? How can avoid it?
Thanks!
I have an xml file structured like this:
Code: Select all
<root>
<nodeA>
<nodeB>
<nodeC>0</esiste>
<nodeD>abcd</id_tensione>
<nodeE>abcd</nodeE>
<nodeF>0</metri>
</nodeB>
<nodeB>
<nodeC>0</esiste>
<nodeD>abcd</nodeD>
<nodeE>abcd</nodeE>
<nodeF>0</nodeF>
</nodeB>
</nodeA>
<nodeA>
<nodeB>
<nodeC>0</nodeC>
<nodeD>abcd</nodeD>
<nodeE>abcd</nodeE>
<nodeF>0</nodeF>
</nodeB>
<nodeB>
<nodeC>0</nodeC>
<nodeD>abcd</nodeD>
<nodeE>abcd</nodeE>
<nodeF>0</nodeF>
</nodeB>
</nodeA>
</root>
Code: Select all
<iso:pattern>
<iso:rule context="nodeB">
<assert test="exists(nodeF) and nodeF > 0">nodeA[<value-of select="(index-of(../../nodeA, ..)-1)" />].nodeB[<value-of select="(index-of(../nodeB, self::node())-1)" />].nodeF#Some message.
</assert>
</iso:rule>
</iso:pattern>
Thanks!

-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Schematron and Java
The index-of returns a sequence. Note that what you want is to check for a specific node and in that case you should use generate-id() to obtain a unique number for that node, something like
You need a similar change also for nodeB.
Best Regards,
George
Code: Select all
index-of(../../nodeA/generate-id(), ../generate-id())-1)
Best Regards,
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service