[Home] [By Thread] [By Date] [Recent Entries]
Another approach, using David's markup, is to allow the rule/@context to do the work of the iteration. This way, you get a message on the queen in question, which is more useful for locating the problem, at the cost of probably re-visiting nodes, unless there is some memoization going on. Also, I am using sch:report so that it matches the text, which is saying what should not be, rather asserting what should be. Note that (assuming it works...untested...) This only uses XSLT1 XPath, too. <sch:schema xmlns:sch="http:// queryBin <sch:pattern id="n-Queens- <sch:rule context=" <sch:report test="@column = following-sibling::queen/@column"> There cannot be two queens in the same column. </sch:report> <sch:report test="@row = following-sibling::queen/@row"> There cannot be two queens on the same row. </sch:report> <sch:report test="following-sibling::queen [(@row - @column) = (current ()/@row - @current ()/@column) ]"> There cannot be two queens on a (falling) diagonal. </sch:report> <sch:report test="following-sibling::queen [(@row + @column) = (current ()/@row + @current ()/@column) ]"> There cannot be two queens on a (rising) diagonal. </sch:report> </sch:rule> </sch:pattern> </sch:schema> Rick On 3 Apr 2017 00:02, "u123724" <u123724@g...> wrote: A solution to the N-queens problem in XSLT was discussed on this
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |

Cart



